标签:math return code inpu == mod tput inf cti
一个数N(1 <= N <= 10^9)
共K行:每行2个数,i j,表示N = i^2 + j^2(0 <= i <= j)。 如果无法分解为2个数的平方和,则输出No Solution
130
3 11 7 9
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <vector> 6 #include <cstdlib> 7 #include <iomanip> 8 #include <cmath> 9 #include <ctime> 10 #include <map> 11 #include <set> 12 using namespace std; 13 #define lowbit(x) (x&(-x)) 14 #define max(x,y) (x>y?x:y) 15 #define min(x,y) (x<y?x:y) 16 #define MAX 100000000000000000 17 #define MOD 1000000007 18 #define pi acos(-1.0) 19 #define ei exp(1) 20 #define PI 3.141592653589793238462 21 #define INF 0x3f3f3f3f3f 22 #define mem(a) (memset(a,0,sizeof(a))) 23 typedef long long ll; 24 const int N=10005; 25 const int mod=1e9+7; 26 27 int main() 28 { 29 int n; 30 cin>>n; 31 int m=(int)sqrt(n)+0.5; 32 int i,j=1; 33 int flag=1; 34 for(i=m;i>=1;i--){ 35 for(j=0;j<=i;j++){ 36 if(i*i+j*j==n){ 37 flag=0; 38 cout<<j<<" "<<i<<endl; 39 } 40 } 41 } 42 if(flag) cout<<"No Solution"<<endl; 43 return 0; 44 }
标签:math return code inpu == mod tput inf cti
原文地址:http://www.cnblogs.com/shixinzei/p/7257075.html