Hehe hey, again a FA shui question ...
"Portal": http://codevs.cn/problem/1083/
>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> Original Question >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>
1083 Cantor Table1999 NOIP National League popularity Grouptime limit: 1 sspace limit: 128000 KBtitle level: Silver
Title Description Description
One of the well-known proofs of modern mathematics is that Georg Cantor proves that rational numbers are enumerable. He used the following chart to prove the proposition: 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 ... 3/1 3/2 3/3 ... 4/1 4/2 ... 5/1 ... We give each item number in the table in zigzag. The first item is 1/1, then the 1/2,2/1,3/1,2/2, ...
Enter a description input Description
Integer N (1≤n≤10000000)
outputs description output Description
The nth item in the table
sample input to sample
7
Sample output Sample outputs
1/4
data size & Hint
See description
>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> Problem Analysis >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>
At a glance, thought to enumerate, the whole table out, and then found that the more familiar with the picture, the figure is rotated, this is not the primary school books on the digital pyramid and so on mdzz ...
It's obvious that *&¥ ... Isn't it?
Well, then, it can be found that each line ends "the number of the end of the singular line at the far right, the number of even lines opposite" is clearly the ordinal "I means line I" "is the Gaussian summation formula (first item + last item) * Number of items/2 reduction results", and the beginning of each line of the number is -i+1, so if you want to know the number of the given ordinal in the first line, you can enumerate from line one to line 4500 "This 4500 is what I use for the loop to estimate when the n=4500 is roughly close to 10000000 (about 10 million a bit)", When the first discovery of the given n is less than the description found the nth number of rows I, and then processed to jump out of the loop output results OK AH
And then found that the law of the number of "after the rotation of the state" is the singular line of the molecules are ascending from left to right, even the molecules from right to left, the corresponding line of the denominator is just the opposite drop, know the law is good to do ... A word does not fit the code ...
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>> My Code >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
var
u,d,n,i:longint;
begin
read(n);
for i:= 1 to 4500 do
if (i+i*i) div 2>= n then
begin
if odd(i) then begin//如果是单数行就是分子从左往右递增,
u:=(i+i*i) div 2-n+1;
d:= n+i-(i+i*i) div 2;
end
else begin//偶数行和单数行相反
d:=(i+i*i) div 2-n+1;
u:= n+i-(i+i*i) div 2;
end;
break;//别忘记跳出循环
end;
write(u,‘/‘,d);//输出结果
end.
Hehe hey, in fact, in the Guide debugging completed after the submission, the results found a one-time pass, moved to that is ...
"Oops ~ yards loadline the good fortune ... If it is helpful to you, the trouble is below the sound ... Thank you
"1083" Code[vs] 1083 Cantor table 1999 NOIP National League popularity Group