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 |
Why WA ?????#include <stdio.h> #include <iostream> using namespace std; #define MAX 3000 #define MAXPRIME 2240 int veces[MAXPRIME + 1],f = 0,aux; int factor[MAXPRIME + 1]; bool criba[MAX] = {0} ; int primos[MAXPRIME + 1]; void init_criba(){ int cant = 0; primos[cant++] = 2; for (int i=3;i<=MAX ;i+=2) { if(!criba[i]){ primos[cant++] = i; for(int j=2;j<=MAX/i;j++) criba[i*j] = true; } } }//criba void inserta_factor(int fact){ if (fact != aux) f++, factor[f-1] = fact, veces[f-1] = 1, aux = fact; else veces[f-1]++; } void factoriza(int n){ int i = 0; while(primos[i]*primos[i] <= n) if (n % primos[i] == 0) inserta_factor(primos[i]), n /= primos[i]; else i++; if (n > 1) inserta_factor(n); } int divNumbers( int n ){ int div = 1; factoriza( n ); for (int i=0; i<f; i++) div *= veces[i]+1; return div; } int main() { init_criba(); int p,number; __int64 result = 0; scanf("%d",&p); while( p-- ) { scanf("%d",&number); int counter = divNumbers( number ); for(int i=1;i<=counter;i++) result+= i*i*i; printf("%I64d\n",result); result = 0; f = 0; aux = 0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator