271 条题解
-
0CYYDS LV 7 @ 2014-07-16 16:25:16
#include <stdio.h>
int main()
{
int n,k;
double x;
scanf("%d",&k);
n=0;
x=0;
while (x<=k)
{
n++;
x=x+1.0/n;
}
printf("%d",n);
return 0;
} -
02014-07-16 16:22:17@
#include <stdio.h>
int main()
{
int n,k;
double x;
scanf("%d",&k);
n=1;
x=0;
while (x<=k)
{
x=x+1/n;
n++;
}
printf("%.lf",n);
return 0;
}
为什么过不了 -
02014-07-04 10:18:31@
var n,k,i:longint;
x:real;
begin
readln(k);
x:=0;
i:=0;
while x<=k do
begin
inc(i);
x:=x+1/i;
end;
writeln(i);
end. -
02013-11-30 09:09:11@
var k,n:longint;
s :real;
begin
s:=0;
k:=0;
readln(n);
if (n>=1) and (n<=15) then begin
while s<=n do begin
k:=k+1;
s:=s+1/k;
end;
write(k);
end;
end. -
02013-11-27 17:36:40@
var k,n:longint;
s :real;
begin
s:=0;
k:=0;
readln(n);
if (n>=1) and (n<=15) then begin
while s<=n do begin
k:=k+1;
s:=s+1/k;
end;
write(k);
end;
end. -
02013-11-25 13:37:46@
#include<cstdio>
main(){long long k,n,i;
double ans=0;scanf("%I64d",&k);
for(i=1;;i++){ans=ans+1.0/i;if(ans>k){printf("%I64d\n",i);break;}}} -
02013-11-07 22:21:18@
program Project1;
var i,k:longint;
x:double;
begin
readln(k);
for i:=1 to 1838000 do begin
x:=x+1 / i;
if x>k then begin
writeln(i);
break;
end;
end;
end. -
02013-10-14 18:45:31@
var n,ans:longint;
mid:double;
begin
read(n);
mid:=1;ans:=1;
while mid<=n do
begin
inc(ans);
mid:=mid+1/ans;
end;
writeln(ans);
end. -
02013-10-08 15:49:10@
这题一般时间消耗要上15ms,还要占掉500K上下的内存。
下面介绍一种方法,全0msPASS且内存只占450上下。C++ Code:
#include <iostream>
using namespace std;
int main(){
int k;
cin>>k;
switch(k){
case 1:
cout<<"1";
break;
case 2:
cout<<"4";
break;
case 3:
cout<<"11";
break;
case 4:
cout<<"31";
break;
case 5:
cout<<"83";
break;
case 6:
cout<<"227";
break;
case 7:
cout<<"616";
break;
case 8:
cout<<"1674";
break;
case 9:
cout<<"4550";
break;
case 10:
cout<<"12367";
break;
case 11:
cout<<"33617";
break;
case 12:
cout<<"91380";
break;
case 13:
cout<<"248397";
break;
case 14:
cout<<"675214";
break;
case 15:
cout<<"1835421";
break;
}
} -
02013-10-08 15:41:27@
这。。。这题是多水。。。要是数据再大一点就高精了。。。15个数据也太那啥了
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int k;
cin>>k;
long n=0;
double sn=0;
while(sn<=k){
n+=1;
sn=sn+1/(double)n;
}
cout<<n;
} -
02013-10-07 14:02:28@
var k,n:longint;
x:real;
begin
readln(k);
case k of
0:write('1');
1:write('2');
2:write('4');
3:write('11');
4:write('31');
end;
if k>4 then begin
n:=0;x:=0;
repeat
n:=n+1;x:=x+1/n;
until x>k;
write(n);
end;
end.
It is very water.
别的题做不出,只能拿这些水题来发泄一下。 -
02013-08-07 18:14:10@
=.=+ 一次AC
看来只有刷水题来抚平我的情绪了= =
Var i,k:int64;
x:extended;
Begin
readln(k);
While x<=k do
Begin
inc(i);
x:=x+1/i;
End;
writeln(i);
readln;
End. -
02013-07-25 19:50:54@
我去,原来要把int换成double。。。。死了两次
-
02013-07-20 18:12:04@
太水了,连我都做得出
一遍AC
VijosEx via JudgeDaemon2/13.7.4.0 via libjudge编译成功
测试数据 #0: Accepted, time = 0 ms, mem = 728 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 732 KiB, score = 10
测试数据 #2: Accepted, time = 31 ms, mem = 732 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 728 KiB, score = 10
测试数据 #4: Accepted, time = 31 ms, mem = 732 KiB, score = 10
Accepted, time = 77 ms, mem = 732 KiB, score = 50
var k,n:longint;
x:real;
begin
readln(k);
case k of
0:write('1');
1:write('2');
2:write('4');
3:write('11');
4:write('31');
end;
if k>4 then
begin
n:=0;
x:=0;
repeat
n:=n+1;
x:=x+1/n;
until x>k;
write(n);
end;
end. -
02012-11-16 22:10:49@
今日放假,见一水题,刷之以庆!
点这里查看程序源码+详细题解
-
02012-11-02 21:16:37@
#include
int main()
{
long k,n;
double sn;
scanf("%ld",&k);
for(n=2;n=k)
printf("%ld",n);break;}
return 0;
} -
02012-09-27 19:25:01@
编译通过...
├ 测试数据 01:答案正确... (0ms, 580KB)
├ 测试数据 02:答案正确... (0ms, 580KB)
├ 测试数据 03:答案正确... (0ms, 580KB)
├ 测试数据 04:答案正确... (0ms, 580KB)
├ 测试数据 05:答案正确... (0ms, 580KB) -
02012-08-24 08:32:00@
算法:直接计算
-
02012-08-08 22:20:39@
打表做吧,提前算好1~10的到时候直接输出就好了
-
02012-07-24 10:20:40@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
好吧。一开始我也没看范围。这是个毛病
var n,k:longint;
num:real;
begin
readln(k);
while num