这个题本来很容易,特水,结果因为读题不认真。。没有注意到,
Cows that are superpals of themselves are shunned; do not consider them! 这句话,导致纠结了好长好长时间 ,
下次读题先认真一些!!!
另外,这个数据量是18000, 一共就不到10组数字,可以打表;
下面附代码:
直接做:
/* Accepted 3711 C++ 0.5K 0'00.59" 1352K */ #include <iostream> using namespace std; int n,s,p; bool func(int k) { int sum=1,summ=1; for(int i=2;i*2<=k;i++) if(k%i==0)sum+=i; for(int i=2;i*2<=sum;i++) if(sum%i==0) summ+=i; if(k==summ&&k!=sum) { s=k;p=sum; return true; } else return false; } int main() { while(cin>>n) { for(int i=n;;i++) if(func(i)) break; cout<<s<<" "<<p<<endl; } }
/* Accepted 3711 C++ 0.5K 0'00.00" 1352K */ #include <iostream> using namespace std; int s[24][2]={{1,1},{220,284}, {1184,1210},{2620, 2924},{5020,5564},{6232,6368}, {10744,10856},{12285,14595},{17296,18416}}; int main() { int n,k; while(cin>>n) { bool f=1; k=0; while(1) { if(n>s[k][1])k++; else if(n<=s[k][0]) {f=0;break;} else if(n>s[k][0]&&n<=s[k][1]) break; } if(f) cout<<s[k][1]<<" "<<s[k][0]<<endl; else cout<<s[k][0]<<" "<<s[k][1]<<endl; } }