Code: Select all
long long odd_num(long long num)
i deleted the odd_num and type into main...
it become AC...
it seems like ACM doesn't accept function!?

and thx anyway Jan~

Moderator: Board moderators
Code: Select all
long long odd_num(long long num)
Code: Select all
#include <stdio.h>
int main(void) {
long long x = 1;
int done = 0;
while (done != 1) {
scanf("%ld", &x);
if (x == 0)
done = 1;
else {
x += 1;
x /= 2;
printf("%ld\n", (3 * ((2 * (x * x)) - 3)));
}
}
return 0;
}
Re: 913 - Joana and the Odd Numbers
Post by sizogee on Wed Sep 10, 2008 3:24 am
Getting TLE...
Code: Select all
#include<stdio.h>
int main()
{
int n,m,p,num;
long long sum_tot,sum_even,tot_sum,lst3_sum,lst_trm;
while(scanf("%d",&num)==1)
{
n=num-2;
m=n-1;
p=m/2;
sum_tot=n*(n+1)/2;
sum_even=p*(p+1);
tot_sum=sum_tot-sum_even;
tot_sum*=2;
printf("%lld\n",tot_sum);
lst_trm=(tot_sum+2*num)-1;
lst3_sum=(3*lst_trm)-6;
printf("%lld\n",lst3_sum);
}
return 0;
}
Code: Select all
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int n,x,y;
int N[63];
int m;
while(1){
printf("n:");
scanf("%d",&n);
while(n%2==1){
x=n/2;
m=(1+(2*x)-1)*x+1;
N[0]=m;
//printf("m=%d\n",N[0]);
for(int i=0;i<n;i++){
N[i]=m+2*i;
// printf("%d\t",N[i]);
}
break;
}
if(n%2==1){
y=N[n-1]+N[n-2]+N[n-3];
printf("%d",y);
printf("\n");}
else break;
}
system("PAUSE");
return EXIT_SUCCESS;
}
The result may not fit in 32 bit integer..rebecca6212 wrote:can anybody tell me what's wrong with the code?
thank you![]()
i am not understand how i can solve it?
write me algorithm, or give me short hints to solve this problem