12541

#include <iostream> #include <sstream> #include <stdio.h> #include <string> #include <math.h> using namespace std; int main() { int n; double max_,min_; double day,month,yr; string s,name,young,old; stringstream ss; bool f=false; cin>>n; //getchar(); while(n–) { cin>>name>>day>>month>>yr; yr+=((month/12)+(day/365)); if(!f) { max_=yr; young = name; min_=yr; old = name; f=1; } else { if(yr>max_) { max_=yr; young = name; }

12543

#include <iostream> #include <string> #include <math.h> using namespace std; int main() { string s,maxStr,a; int max_=0; int len=0; maxStr=""; while(cin>>s) { if(s=="E-N-D") break; len=0; a=""; for(int i=0;i<s.size();i++) { if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z') || s[i]=='-') { len++; if(s[i]>='A' && s[i]<='Z') a.append(1u,s[i]+32); else a.append(1u,s[i]); } } if(len>max_) { max_=len; maxStr=a; } } cout<<maxStr<<"\n"; return

10780

#include <iostream> #include <cstring> #include <math.h> #include <stdio.h> #include <vector> #include <fstream> #define ull unsigned long long using namespace std; int factor[10001][1230]; int factorcount[10001][1230]; int prime[10001]; vector<int> v; ull _MAX; void primegenerator() { double p=sqrt(10001); v.push_back(2); for(int i=3;i<p;i+=2) { if(prime[i]==0) for(int j=i*i;j<10001;j+=i) prime[j]=1; } for(int i=3;i<10001;i+=2) { if(prime[i]==0) v.push_back(i); } } void factorize() { for(int

10308

This is the problem to find the tree diameter. #include <iostream> #include <fstream> #include <sstream> #include <map> #include <vector> #include <string> #include <queue> #include <string.h> #include <stdio.h> #define ull unsigned long long #define SZ 10002 #define FOR(i,a) for(int i=0;i<a;i++) using namespace std; vector<int> graph[SZ]; bool visit[SZ]; int distnce[SZ][SZ]; ull distnode[SZ]; ull max_dist=0; int farthestnode; void

10394

#include <iostream> #include <string> #include <vector> #include <math.h> #define SZ 20000001 using namespace std; int prime[SZ]; vector<int> v; struct twin{ int x; int y; }twinPrime[108001]; void primegen() { double p = sqrt(SZ); for(int i=3;i<p;i+=2) { if(prime[i]==0) { for(int j=i*i;j<SZ;j+=i) prime[j]=1; } } v.push_back(2); int cnt=0; for(int i=3;i<SZ;i+=2) { if(prime[i]==0) { v.push_back(i); int t=v.size(); if(v[t-1]-v[t-2]==2) {

11709

#include <iostream> #include <map> #include <vector> #include <string> #include <queue> #include <string.h> #include <stdio.h> using namespace std; vector<int> graph[1005]; bool visit[1005]; bool visited[1005][1005]; map<string,int> mp; int p,t; void dfs(int u,int v) { visited[u][v]=1; int tmp; for(int i=0;i<graph[v].size();i++) { tmp=graph[v][i]; if(!visited[u][tmp]) { dfs(u,tmp); } } } int main() { string s,s1; while(cin>>p>>t) { if(p==0 && t==0)

11347

#include <iostream> #include <cstring> #include <math.h> #include <stdio.h> #include <vector> #define ull unsigned long long #define max(a,b) a>=b?a:b using namespace std; int ans[200]; int prime[1001]; vector<int> v; ull _MAX; void primegenerator() { double p=sqrt(1001); v.push_back(2); for(int i=3;i<p;i+=2) { if(prime[i]==0) for(int j=i*2;j<1001;j+=i) prime[j]=1; } for(int i=3;i<1001;i+=2) { if(prime[i]==0) v.push_back(i); } } int main() { string s;

11415

#include <iostream> #include <math.h> #include <vector> #define ull unsigned long long #define SIZE 2703664 using namespace std; int prime[1700];//3200 ull factor[SIZE]; int arr[10000001]; vector<int> v; void primeGenerator() { double p = sqrt(1700); for(int i=3;i<p;i+=2) { if(prime[i]==0) { for(int j=i+i;j<1700;j+=i) prime[j]=1; } } v.push_back(2); for(int i=3;i<1700;i+=2) { if(prime[i]==0) v.push_back(i); } } void countfactor() { int tmp;

10856

#include <iostream> #include <string> #include <stdio.h> #include <math.h> #include <vector> #include <stdlib.h> #define SIZE 2800001 #define ull unsigned long long using namespace std; int prime[1700]; ull arr [SIZE];//[10000001+5]; vector<int> v; void primeGenerator() { double p = sqrt(1700); for(int i=3;i<p;i+=2) { for(int j=i+i;j<1700;j+=i) { prime[j]=1; } } v.push_back(2); for(int i=3;i<1700;i++) { if(prime[i]==0 && i%2!=0) { v.push_back(i);

10139

#include <iostream> #include <math.h> #include <vector> #include <map> #include <sstream> #include <fstream> #define SIZE 46500 #define lld long long using namespace std; // sqrt of 2^31 is ~46400 vector<int> v; int prime[SIZE]; void PrimeGenerate() { double p = sqrt(SIZE)+4; for(int i=3;i<p;i+=2) { if(prime[i]==0) { for(int j=i+i;j<SIZE;j+=i) prime[j]=1; } } v.clear(); v.push_back(2); for(int j=3;j<SIZE;j++) { if(prime[j]==0