Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
0ms~~~开心 弄了4次 终于写出0MS的拉!!!!#include<iostream> using namespace std; int a[101]={0}; int main() { int n; int i,j,k,l;; for(i=1;i<=100;i++) { a[i]=i*i*i; } scanf("%d",&n); for(i=6;i<=n;i++) { for(j=2;j<=n;j++) { for(k=j+1;k<=n;k++) { if((a[j]+a[k])>a[i]) break; for(l=k+1;l<=n;l++) { if((a[j]+a[k]+a[l])>a[i]) break; if(a[i]==a[j]+a[k]+a[l]) { printf("Cube = %d, Triple = (%d,%d,%d)\n",i,j,k,l); } } } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator