#include <iostream> #include <map> #include <string> using namespace std; map<char,int> mp; map<int,int> np; int main() { mp['A']=2; mp['B']=2; mp['C']=2; mp['D']=3; mp['E']=3; mp['F']=3; mp['G']=4; mp['H']=4; mp['I']=4; mp['J']=5; mp['K']=5; mp['L']=5; mp['M']=6; mp['N']=6; mp['O']=6; mp['P']=7; mp['R']=7; mp['S']=7; mp['T']=8; mp['U']=8; mp['V']=8; mp['W']=9; mp['X']=9; mp['Y']=9; mp['0']=0; mp['1']=1; mp['2']=2; mp['3']=3; mp['4']=4; mp['5']=5; mp['6']=6; mp['7']=7; mp['8']=8; mp['9']=9; int t,n,num; string str; cin>>t;
Year: 2014
10852
#include <iostream> #include <map> #include <fstream> /* ofstream out; out.open("o.txt"); for(int i=0;i<11000;i++) prime[i]=0; for(int i=2;i<11000/2;i++) { if(prime[i]==0) for(int j=i+i;j<11000;j+=i) { prime[j]=1; } } int cnt=0; for(int i=2;i<10000;i++) { if(prime[i]==0) { out<<i<<","; cnt++; if(cnt%10==0) out<<"\n"; } } cout<<cnt<<"\n"; out.close(); */ using namespace std; //int prime[11000]; int prime[1230]={0,2,3,5,7,11,13,17,19,23,29, 31,37,41,43,47,53,59,61,67,71, 73,79,83,89,97,101,103,107,109,113, 127,131,137,139,149,151,157,163,167,173, 179,181,191,193,197,199,211,223,227,229, 233,239,241,251,257,263,269,271,277,281, 283,293,307,311,313,317,331,337,347,349, 353,359,367,373,379,383,389,397,401,409, 419,421,431,433,439,443,449,457,461,463, 467,479,487,491,499,503,509,521,523,541,
725
#include <iostream> #include <stdio.h> #include <map> #include <vector> using namespace std; map<int,int> m,n; vector<int> den[80]; vector<int> numer[80]; int main() { int cnt,org; for(int i=0;i<80;i++) { den[i].clear(); numer[i].clear(); } for(int i=1234;i<=98765;i++) { if(i%10==0 && i<10000) continue; org=i; m.clear(); if(i<10000) m[0]=1; while(org) { if(m[org%10]) break; m[org%10]=1; org/=10; } if(org) continue; cnt=1; for(int j=i*2;j<100000;j+=i) { cnt++; if(i<10000 &&
1213
Hint: Start from 1120 not to count same prime. #include <iostream> using namespace std; int dp[1121][15]; int main() { int n,k; int prme[189]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127, 131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349, 353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673, 677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809, 811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117, 1123, 1129}; for(int i=0;i<1121;i++) { for(int j=0;j<15;j++) { dp[i][j]=0; } } dp[0][0]=1; for(int i=0;i<187;i++) { for(int j=1120;j>=prme[i];j–) { for(int k=1;k<=14;k++) { dp[j][k]+=dp[j-prme[i]][k-1]; } } } /*for(int i=0;i<189;i++) for(int
12335
Problem Solving Head start: Discussion is quoted from this link: So before proceed recall,if a<b<c<d and string is- abcd, there are 24 permutation,where 1-6 permutation start with smallest, here a. 7-12 permutation start with second smallest, here b. 13-18 permutation start with third smallest, here c. 19-24 permutation start with fourth smallest, here d. lets
12302
Theory: Construction of the Nine-Point Circle 1. Draw a triangle ABC. 2. Construct the midpoints of the three sides. Label them as L, M, N. 3. Construct the feet of the altitudes of the triangle ABC. Label them as D, E, F. Label the point of intersection of the three altitudes as H. This
12347
#include <iostream> #include <vector> #include <algorithm> #include <fstream> using namespace std; int pre[10001]; int in[10001]; ofstream wrt; int search(int _in[],int a,int len) { for(int i=0;i<len;i++) { if(_in[i]==a) return i; } return -1; } void printPostOrder(int _in[],int _pre[],int n) { int root=search(_in,_pre[0],n); if(root!=0) printPostOrder(_in,_pre+1,root); if(root!=n-1) printPostOrder(_in+root+1,_pre+root+1,n-root-1); cout<<_pre[0]<<"\n"; //wrt<<_pre[0]<<"\n"; } int main() { int i=0; int a;
12376
#include <iostream> #include <vector> #include <queue> using namespace std; int value[104]; vector<int> vb[104]; int visit[104]; queue<int> ue; int learned; int _next; int findAns(int a) { int _max=0; if(vb[a].size()==0) { _next=a; //learned+=value[a]; return 0; } else { for(int i=0;i<vb[a].size();i++) { if(value[i]]>_max) { _max=value[i]]; _next=vb[a][i]; } } learned+=_max; return findAns(_next); } return 0; } int main() {
12372
#include <iostream> using namespace std; int main() { int t,l,w,h; int c=1; cin>>t; while(t–) { cin>>l>>w>>h; if(l>20 || w>20 || h>20) cout<<"Case "<<c++<<": bad\n"; else cout<<"Case "<<c++<<": good\n"; } return 0; }
12397
#include <iostream> #include <stdio.h> #include <math.h> #include <string> #include <map> using namespace std; map<int,char> mp; int main() { int n,p; string str; mp[1]='I'; mp[5]='V'; mp[10]='X'; mp[50]='L'; mp[100]='C'; mp[500]='D'; mp[1000]='M'; //mp[2]= while(cin>>n) { str=""; int cnt=0; p=0; if(n>=1000) { p=n/1000; cnt+=p*4; n-=1000*p; } p=0; if(n>=100) { p=n/100; if(p==1) cnt+=2; else if(p==2) cnt+=4; else if(p==3) cnt+=6; else