- Cantor表
- 2013-10-07 14:01:08 @
var
n,i,a,b:longint;flag:boolean;
function w(i:longint):longint;
var
j:longint;
begin
w:=0;
for j:=1 to i do
w:=w+j;
end;
begin
read(n);
for i:=1 to 1000 do begin
if n<=w(i) then begin a:=i;n:=n-w(i-1);break;end;
end;
if a mod 2=0 then flag:=false else flag:=true;
b:=1;
if flag then begin
for i:=a downto 1 do begin
if b=n then begin writeln(i,'/',a-i+1);halt;end else inc(b);
end;end
else begin
for i:=1 to a do begin
if b=n then begin writeln(i,'/',a-i+1);halt;end else inc(b);
end;
end;
end.
6 条评论
-
Antman LV 9 @ 2016-09-19 18:54:08
实在看不懂...orz
-
2016-09-19 18:53:49@
orz...
-
2016-07-01 22:29:07@
C++党
#include <cstdio>
#include <iostream>using namespace std;
int n,sum = 1,i = 1;
bool flag = false;int main(){
cin >> n;
while(sum < n) sum += ++i;
sum -= i; n -= sum;
if(i%2) cout << i+1-n << "/" << n << endl;
else cout << n << "/" << i+1-n << endl;return 0;
} -
2015-03-19 19:06:52@
为何如此复杂。。
-
2014-06-24 20:50:20@
var n:longint;
begin
readln(n);
writeln(trunc((1+sqrt(8*n-7))/2)+1-((2*ord(odd(trunc((1+sqrt(8*n-7))/2)))-1)*((n-(trunc((1+sqrt(8*n-7))/2)*trunc((1+sqrt(8*n-7))/2)-trunc((1+sqrt(8*n-7))/2)+2)div 2+1)*2-trunc((1+sqrt(8*n-7))/2)-1)+trunc((1+sqrt(8*n-7))/2)+1)div 2,'/',((2*ord(odd(trunc((1+sqrt(8*n-7))/2)))-1)*((n-(trunc((1+sqrt(8*n-7))/2)*trunc((1+sqrt(8*n-7))/2)-trunc((1+sqrt(8*n-7))/2)+2)div 2+1)*2-trunc((1+sqrt(8*n-7))/2)-1)+trunc((1+sqrt(8*n-7))/2)+1)div 2)
end. -
2013-10-07 16:59:11@
var
i,j,n,k,b:longint;
f:boolean;
begin
readln(n); f:=false;
for k:=1 to n do
begin
for b:=1 to k do
begin
n:=n-1;
if n=0 then begin f:=true;i:=b;break; end;
end;
if f then begin j:=k;break; end;
end;
if j mod 2=0 then writeln(i,'/',j-i+1)
else writeln(j-i+1,'/',i);
end
- 1