CD1618
来源:互联网 发布:现货白银分钟线数据 编辑:程序博客网 时间:2024/06/07 10:51
//还是WA了。#include<iostream>#include<stdlib.h>#include<math.h>#include<stdio.h>#include<algorithm>#include<queue>#include<string.h>#include<stack>#include<math.h>#include<string>#include<stdlib.h>#include<list>#include<vector>using namespace std;int go[10000];int hi[10000];int find(int k){ for (int i=0;i<10000;i++) { //cout<<go[i]<<' '<<k<<endl; if (go[i]==k) return i; }}int make(int i,int j){ int k; if (j==0) return i; k=find(i); //cout<<k<<endl; if (j==1) return go[k+1]; return make(go[k+1],go[find(j)-1]);}int main(){ int i,j,k; int t; cin>>t; for (i=0;i<10000;i++) go[i]=i*i; while (t--) { cin>>i>>j; cout<<make(i,j)<<endl;; } }
SaSet
Time Limit: 1000 ms Memory Limit: 65536 kB Solved: 137 Tried: 321
Description
Saya defines a set consists of square numbers({i|i=x^2,x∈N} or {0,1,4,9,16…}) called Saya Set(SaSet for short). The addition on this set is defined by Saya:
(min(S) here is a function which returns the minimum element in the given set S. For example, min(SaSet)=0.)
Examples:
0+1=1,1+1=4,4+1=9…
(max(S) here is a function which returns the maximum element in the given set S.)
Example:
1-1=0,4-1=1,9-1=4…
Example:
4+4=4+1+(4-1)=9+1=16
Input
There is only one integer T(1<=T<=50) in the first line, which denotes the number of test cases.
Then T lines follows, each line will consists of two integers a and b(0<=a+b<=400,a,b∈SaSet). You are asked to calculate the answer of a+b.
??
Output
For each case, output an integer, which denotes the result of a+b according to the definitions above.
Simple Input
2
0 0
4 4
Simple Output
0
16