题解

64 条题解

  • -1
    @ 2014-08-12 11:10:56

    测试数据 #0: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 0 KiB, score = 10
    Accepted, time = 0 ms, mem = 0 KiB, score = 100

  • -1
    @ 2006-11-14 20:56:12

    我觉得很难......

    PS:我是菜鸟

  • -2
    @ 2015-10-17 21:39:53

    #终于AC了

    P1308埃及分数Accepted
    记录信息
    评测状态 Accepted
    题目 P1308 埃及分数
    递交时间 2015-10-17 21:39:08
    代码语言 C++
    评测机 VijosEx
    消耗时间 730 ms
    消耗内存 528 KiB
    评测时间 2015-10-17 21:39:10
    评测结果
    编译成功

    foo.cpp: In function 'void print()':
    foo.cpp:16:23: warning: unknown conversion type character 'l' in format [-Wformat=]
    printf("%lld ",ans[i]);
    ^
    foo.cpp:16:23: warning: too many arguments for format [-Wformat-extra-args]
    foo.cpp: In function 'int main()':
    foo.cpp:59:28: warning: unknown conversion type character 'l' in format [-Wformat=]
    scanf("%lld %lld",&a,&b);
    ^
    foo.cpp:59:28: warning: unknown conversion type character 'l' in format [-Wformat=]
    foo.cpp:59:28: warning: too many arguments for format [-Wformat-extra-args]
    测试数据 #0: Accepted, time = 0 ms, mem = 528 KiB, score = 10
    测试数据 #1: Accepted, time = 15 ms, mem = 528 KiB, score = 10
    测试数据 #2: Accepted, time = 15 ms, mem = 524 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 528 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 524 KiB, score = 10
    测试数据 #5: Accepted, time = 15 ms, mem = 524 KiB, score = 10
    测试数据 #6: Accepted, time = 171 ms, mem = 528 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 524 KiB, score = 10
    测试数据 #8: Accepted, time = 15 ms, mem = 524 KiB, score = 10
    测试数据 #9: Accepted, time = 484 ms, mem = 528 KiB, score = 10
    Accepted, time = 730 ms, mem = 528 KiB, score = 100
    代码

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    using namespace std;

    long long ans[21],now[21];
    int dep;
    long long GCD(long long x,long long y){return y?GCD(y,x%y):x;}
    void print()
    {
    for(int i=1;ans[i];i++)
    printf("%lld ",ans[i]);
    }
    bool search(long long a,long long b,int k)
    {
    if(k==dep){
    if(a==1){
    now[k]=b;
    if(now[k]<ans[k]||ans[k]==0)
    memcpy(ans,now,sizeof(now));
    return true;
    }
    return false;
    }
    bool flag=false;
    long long first=b%a?b/a+1:b/a;
    for(long long i=max(now[k-1]+1,first);;i++)
    {
    if(b*(dep+1-k)<=i*a) break;
    now[k]=i;
    long long x=a*i-b;
    long long y=b*i;
    long long kt=GCD(x,y);
    if(search((long long)x/kt,(long long)y/kt,k+1))
    flag=true;
    }
    return flag;
    }
    void work(int a,int b)
    {
    for(dep=1;;dep++)
    {
    if(search((long long)a,(long long)b,1)){
    print();
    break;
    }
    }
    }
    int main()
    {
    long long a,b;
    scanf("%lld %lld",&a,&b);
    int kt=GCD(a,b);
    work(a/kt,b/kt);
    return 0;
    }

  • -2
    @ 2009-08-02 14:11:42

    话说此题真的非常经典,但是确实X

    真的.....看我无剪枝暴搜程序过全点,真的很滑稽....

    没什么好说的,就是纯暴力搜索 。。。。最外层枚举分数数量搜索 。。。。

    贴个主体部分

    procedure search(z:longint;x,y:int64);

    var i:longint;

    q,t,p,j,k:int64;

    begin

    if (y mod x=0) and (y div x>a[z-1]) then

    begin

    a[z]:=y div x;

    if not f or (a[z]0) and (z

信息

ID
1308
难度
8
分类
搜索 | 搜索与剪枝 点击显示
标签
(无)
递交数
3393
已通过
497
通过率
15%
被复制
5
上传者