PersonalCorpus 版 (精华区)

41340 2002-10-13 20:34:23 Accepted
1331 C++ 00:00.97 380K Big Guava

int main()
{
#ifndef ONLINE_JUDGE
    freopen("c:\\0acm\\zju\\i1331","r",stdin);
    freopen("c:\\0acm\\zju\\o1331","w",stdout);
#endif

    int a,b,c,d;
    int power3[201];

    for (a=0;a<201;a++) power3[a]=a*a*a;
    for (a=6;a<201;a++)
        for (b=2;b<a;b++)
            for (c=b;c<a;c++)
                for (d=c;d<a;d++)
                    if (power3[b]+power3[c]+power3[d]==power3[a])
                        printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,
c,d);

}


============================================================================


41344 2002-10-13 20:36:35 Accepted
1331 C++ 00:00.97 380K Big Guava

int main()
{
#ifndef ONLINE_JUDGE
    freopen("c:\\0acm\\zju\\i1331","r",stdin);
    freopen("c:\\0acm\\zju\\o1331","w",stdout);
#endif

    int a,b,c,d;

    for (a=6;a<201;a++)
        for (b=2;b<a;b++)
            for (c=b;c<a;c++)
                for (d=c;d<a;d++)
                    if (b*b*b+c*c*c+d*d*d==a*a*a)
                        printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,
c,d);
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.884毫秒