Posts

Showing posts from 2018

Big Number Factorial

/***  *    author:   kamran_11b  *    created:  29.05.2018 ***/ #include <bits/stdc++.h> using namespace std; void fact(int n) {     int a[205];     int dig=1;     a[0]=1;     for(int i=2; i<=n; i++)     {         int temp=0;         int x;         for(int j=0; j<dig; j++)         {             x=(a[j]*i)+temp;             a[j]=x%10;             x=temp=x/10;         }         while(x)         {             a[dig++]=x%10;             x=x/10;         }     }     for(int i=dig-1; i>=0; i--)     {         cout<<a[i];     }     cout<<endl; } int main() {     int t;     cin>>t;     while(t--)     {         int n;         cin>>n;         fact(n);     } }

Uva-12015 Google is Feeling Lucky

#include<bits/stdc++.h> using namespace std; #define ll              long long #define ull             unsigned long long bool sor1(const pair<string,int>&a,const pair<string,int>&b) {     return (a.second > b.second); } int main() {     ios_base::sync_with_stdio();     int t,c=1;     cin>>t;     while(t--)     {         string s;         int a;         vector<pair<string,int> > v;         for(int i=0; i<10; i++)         {             cin>>s;             cin>>a;             v.push_back(make_pair(s,a));         }         cout<<"Case #"<<c++<<":"<<endl;         sort(v.begin(),v.end(),sor1);         for(int i=0; i<10; i++)         {             if(v[i].second==v[i+1].second)             {                 cout<<v[i].first<<endl;             }             else             {                 cout<<v[i].first<<endl;