11689

#include <iostream> #include <cstdio> using namespace std; int main() { int t; int e,f,c; int total_consumed,total_empty; scanf("%d",&t); while(t–) { scanf("%d%d%d",&e,&f,&c); total_consumed=0; total_empty=e+f; while(total_empty>=c) { total_consumed += (total_empty/c); total_empty = total_empty/c + total_empty%c; } cout<<total_consumed<<"\n"; } return 0; }  

10494

#include <iostream> #include <cstdio> #include <cstring> //#include <fstream> #define ul unsigned long long using namespace std; int quotient[10005]; ul remainder; int main() { char num[10005]; char op[2]; int div; int pos; int j,k; //ofstream out; //out.open("out_10494.txt"); while(scanf("%s%s%d",num,op,&div)!=EOF) { k=0; remainder=0; for(int i=0;i<strlen(num);i++) { quotient[k] = 0; remainder = remainder*10+(num[i]-'0'); quotient[k] = remainder/div; remainder = remainder%div;

11364

#include <iostream> #include <cstdio> #include <vector> #include <stack> #include <cmath> #include <cstring> #include <string> #include <algorithm> #define INF 1000000000 #define ll long long using namespace std; vector<int> vb; int main() { int t,n,a; ll dist; scanf("%d",&t); while(t–) { scanf("%d",&n); vb.clear(); for(int i=0;i<n;i++) { scanf("%d",&a); vb.push_back(a); } sort(vb.begin(),vb.end()); dist=0; for(int i=1;i<n;i++) dist+=(vb[i]-vb[i-1]); dist+=(vb[n-1]-vb[0]); printf("%lld\n",dist); } return

1225

#include <iostream> #include <cstdio> #include <vector> #include <queue> #include <sstream> #include <string> #include <cstring> #include <cmath> #define ll long long using namespace std; ll digitCount[10]; ll pwr; ll numberOfDigit[15];//total count of i digit numbers int getLength(int a) { if(a<10) { pwr=1; return 1; } int len=0; pwr=1; while(a) { len+=1; a/=10; pwr*=10; } pwr/=10;//10 to

11934

Have some idea about Remainder Theorem, not necessary to solve the problem but it is good to revise some theorem. #include <iostream> #include <cstdio> #include <sstream> #include <string> #define ll long long using namespace std; int main() { int a,b,c,d,L; while(scanf("%d%d%d%d%d",&a,&b,&c,&d,&L)) { if(a==0 && b==0 && c==0 && d==0 && L==0) break; if(a==0 && b==0

11970

#include <iostream> #include <cstdio> #include <queue> #include <sstream> #include <string> #include <vector> #include <cstring> #include <cmath> #define ll long long using namespace std; vector<ll> v; int main() { int t; ll n,sq,sq_root,x; int kase=1; scanf("%d",&t); while(t–) { scanf("%lld",&n); sq=0; int k=0; v.clear(); for(ll i=0;;i++) { sq += 2*i+1; sq_root=i+1; if(sq>=n) break; x = n-sq; if(x%sq_root==0

11121

#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <cmath> #include <cstdlib> #define INF 1000000 #define ll long long using namespace std; int main() { int t,kase=1; ll n; int a=-2,b=-3; //cout<<a%2<<" "<<b%2<<"\n"; string str; scanf("%d",&t); while(t–) { scanf("%lld",&n); if(n==0) { printf("Case #%d: ",kase++); printf("0\n"); continue; } str=""; while(n) { if(n%2)

12459

#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <cstdlib> #include <fstream> #define INF 1000000 #define ll long long using namespace std; struct node{ ll female,male,sum; }; int main() { node fib[85]; fib[1].female=0; fib[1].male=1; fib[1].sum=1; fib[2].female=1; fib[2].male=1; fib[2].sum=2; for(int i=3;i<85;i++) { fib[i].female=fib[i-1].sum; fib[i].male=fib[i-1].female; fib[i].sum=fib[i].male+fib[i].female; } int n; while(scanf("%d",&n)) { if(n==0) break;

11466

There should be a better approach to improve the time complexity. #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <cmath> #define ull unsigned long long #define ll long long using namespace std; bool prime[35000000]; vector<int> prm; int main() { double n; int mxprime,cnt; ull num; for(int i=2;i<35000000;i++) { if(prime[i]==0) { prm.push_back(i); for(int

10533

#include <iostream> #include <cstdio> #include <sstream> #include <string> using namespace std; bool prime[1000001]; bool firstPrime[1000001]; int primeCount[1000001]; bool checkdigit(int a) { int sum; if(a<10) return 1; else { sum=0; while(a) { sum+=a%10; a/=10; } if(firstPrime[sum]==0) return 1; else return 0; } return 0; } int main() { int cnt=0; prime[0]=1; prime[1]=1; firstPrime[0]=1; firstPrime[1]=1; primeCount[0]=cnt; primeCount[1]=cnt;