151 条题解

  • 0
    @ 2013-11-08 08:59:24

    const
    jing=0.0000000001;
    var
    n:longint;
    i:int64;
    x,delta,sum,sum1,sum2:double;
    begin
    readln(n);
    i:=0;
    while i<n-1 do
    begin
    inc(i);
    sum:=i*i-i+2*n;
    delta:=1+4*sum;
    if delta<0 then continue;
    x:=(-1+sqrt(delta))/2;;
    if (abs(x-trunc(x))<=jing) and (x<=n) then writeln(i,' ',x:0:0);
    end;
    end.

    水题不解释。
    设首项为x,末项为y,则(x+y)*(y-x+1)/2=n
    则(x+y)*(y-x+1)=2*n
    化简-x^2+x+y^2+y=2*n
    那么我们可以枚举x
    这样,x^2-x+2n为定值。
    设sum=x^2-x+2n
    则y^2+y=sum
    那么,可以解方程。
    注意精度问题。
    还有,i最好开int64,否则i*i可能会爆

  • 0
    @ 2013-11-08 08:56:45

    设等差数列的起始项为A,末项为B
    项数为B-A+1
    M=(A+B)*(B-A+1)/2
    即2M=(A+B)*(B-A+1)
    将2M质因数分解,得到两个值 S1=A+B S2=B-A+1
    因为S1<=sqrt(2M) 所以可以直接枚举A,检测(B-A+1)*(A+B)是否为2M,是则输出
    Var
    m,a,r,i,j:longint;
    procedure f(p,q:longint);
    var
    x,y:longint;
    begin
    for x:=1 to q-1 do
    if q-2*x+1=p then writeln(x,' ',q-x);
    end;
    begin
    readln(m);
    m:=m*2;
    for a:=trunc(sqrt(m)) downto 2 do
    if m mod a=0 then f(a,m div a);
    end.

  • 0
    @ 2013-11-05 21:07:37

    while m<=n div 2+1 do
    begin
    if trunc(-0.5+sqrt(abs(2*n+m*m-m+0.25)))=-0.5+sqrt(abs(2*n+m*m-m+0.25)) then
    if -0.5+sqrt(abs(2*n+m*m-m+0.25))>m then
    writeln(m,' ',-0.5+sqrt(abs(2*n+m*m-m+0.25)):0:0);
    推等差数列的结果,毫无压力

  • 0
    @ 2013-10-31 20:33:55

    hashing啊!太完美了
    var
    list:array[0..10000000]of longint;
    next,h:array[0..2000000]of int64;
    n,i,xx,tot:longint;
    sum:int64;
    function check(x:int64):longint;
    var
    y,hash:longint;
    begin
    hash:=x mod 10000000;
    y:=list[hash];
    while y<>0 do
    begin
    if h[y]=x then exit(y);
    y:=next[y];
    end;
    exit(-1);
    end;
    procedure ind(x:int64);
    var
    hash:longint;
    begin
    inc(tot);
    hash:=x mod 10000000;
    h[tot]:=x;
    next[tot]:=list[hash];
    list[hash]:=tot;
    end;
    begin
    readln(n);
    for i:=1 to n-1 do
    begin
    sum:=sum+i;
    if (sum>=n) then
    begin
    xx:=check(sum-n);
    if xx<>-1 then
    writeln(xx+1,' ',i);
    end;
    ind(sum);
    end;
    end.

  • 0
    @ 2013-10-30 15:48:16

    var i,j,k,l,m,n:Longint;
    Begin
    Readln(M);
    For i:=1 to M shr 1 do
    For j:=i+1 to i+M do
    Begin
    If (j-i+1)*(j+i) shr 1>M then Break;
    If (j-i+1)*(j+i) shr 1=M then Writeln(i,' ',j);
    End;
    End.

  • 0
    @ 2013-09-21 20:12:54

    第二次秒杀...第一次是A+B problem
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 820 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 820 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 824 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 824 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 824 KiB, score = 20
    测试数据 #5: Accepted, time = 0 ms, mem = 820 KiB, score = 20
    测试数据 #6: Accepted, time = 0 ms, mem = 820 KiB, score = 20
    Accepted, time = 0 ms, mem = 824 KiB, score = 100
    代码
    program p1302;
    var num,n,i,j,k:longint;
    begin
    readln(num);
    for i:=trunc(sqrt(2*num))+1 downto 2 do
    if i mod 2=0 then
    begin
    n:=num div i;
    if (num/i)-trunc(num/i)=0.5 then
    writeln(n-(i div 2)+1,' ',n+(i div 2));
    end else begin
    n:=num div i;
    if (num/i)-trunc(num/i)=0 then
    writeln(n-(i div 2),' ',n+(i div 2));
    end;
    end.

  • 0
    @ 2012-11-09 20:57:04

    var

    n,a,k,e,m:longint;

    o:real;

    begin

    read(m);

    for a:=1 to m do  begin if am then begin

    while k

  • 0
    @ 2012-08-14 22:19:34

    1.5星,留念

  • 0
    @ 2012-08-02 23:58:59

    AC15题纪念!!

    加油!

  • 0
    @ 2012-08-04 07:36:41

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    点击查看代码

  • 0
    @ 2010-07-22 16:23:18

    tiger0576

    program solve;

    var i,j,n,m:longint;

    begin

    readln(n);

    for i:=1 to n div 2 do begin

    for j:=(i+1) to (i+n) do begin

    m:=j-i+1;

    if (i+j)*m=2*n then

    writeln(i,' ',j);

      end;

    end;

    end.

  • 0
    @ 2010-07-07 23:09:34

    编译通过...

    ├ 测试数据 01:答案正确... 103ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:运行超时...

    ├ 测试数据 06:运行超时...

    ├ 测试数据 07:运行超时...

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:40 有效耗时:103ms

    纯模拟真的能过???

  • 0
    @ 2010-04-06 16:15:52

    program solve;

    var i,j,n,m:longint;

    begin

    readln(n);

    for i:=1 to n div 2 do begin

    for j:=(i+1) to (i+n) do begin

    m:=j-i+1;

    if (i+j)*m=2*n then

    writeln(i,' ',j);

    end;

    end;

    end.

  • 0
    @ 2009-11-18 20:08:32

    农夫山泉有点甜,好水喝出健康来!

    #include

    using namespace std;

    int main ()

    {

    int i,j,m,n;

    cin>>m;

    for (i=1;i

  • 0
    @ 2009-11-01 21:45:22

    var i,j,n:longint;

    begin

    readln(n);

    for i:=1 to n div 2 do

    for j:=2 to n do

    begin

    if (i+i+j-1)*j div 2>n then break;

    if (i+i+j-1)*j div 2=n then writeln(i,' ',i+j-1);

    end;

    end.

  • 0
    @ 2009-10-25 18:12:46

    第80道,飘呀~飘呀~

  • 0
    @ 2009-10-25 10:59:34

    var t,s,i,j:longint;m:real;

    begin

    readln(s);

    t:=s shr 1;

    for i:=1 to t do begin

    m:=0.5-i+sqrt(sqr(i-0.5)+2*s);

    if m=int(m) then begin

    writeln(i,' ',i+m-1:0:0);

    end;

    end;

    end.

  • 0
    @ 2009-10-22 16:02:36

    嗯!很好很强大!一重循环即可!

    看了题后,写了个求等差数列和的公式,然后转换了下:

    n=0.5-a+sqrt(sqr(a1-0.5)+2*s)

    再后看了数据范围,于是很高兴的AC

    ---|---|---|---|---|---|---|---|---|---|--

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var t,s,i,j:longint;m:real;

    begin

    readln(s);

    t:=s shr 1;

    for i:=1 to t do begin

    m:=0.5-i+sqrt(sqr(i-0.5)+2*s);

    if m=int(m) then begin

    writeln(i,' ',i+m-1:0:0);

    end;

    end;

    end.

  • 0
    @ 2009-10-17 20:07:01

    我1.5级了...

    枚举秒杀

  • 0
    @ 2009-10-07 19:34:29

    记录号 Flag 得分 记录信息 环境 评测机 程序提交时间

    R1588982 Accepted 100 From |-

      P1302 FPC Vijos Sunny 2009-10-7 19:33:05

    From cqwshll

    连续自然数和

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    枚举 sunny秒杀。

信息

ID
1302
难度
3
分类
数论 | 数位统计 点击显示
标签
(无)
递交数
2539
已通过
1289
通过率
51%
被复制
3
上传者