| ||||||||||
| 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 | |||||||||
很恶心人的英文。。。#include <stdio.h>
#include <string.h>
#include <math.h>
#define FOR(i,s,e) for (int (i)=(s); (i)< (e) ; i++)
typedef __int64 i64;
#define PI 3.1415926
#define DIS(x,y) sqrt((x)*(x)+(y)*(y))
#define STR(s1,s2) strcpy((s1),(s2))
i64 a[6000];
int main()
{
freopen("in.txt","r",stdin);
a[0]=1;
int x[4]={0};
int p[4]={2,3,5,7};
FOR(i,1,5843)
{
FOR(j,0,4)
if (j == 0 || a[x[j]]*p[j] < a[i])
a[i] = a[x[j]]*p[j];
FOR(j,0,4)
if (a[x[j]]*p[j] <= a[i]) x[j]++;
}
int n;
char s[10];
while (scanf("%d",&n),n>0)
{
if(n%10==1&&n%100!=11)
STR(s,"st");
else if(n%10==2&&n%100!=12)
STR(s,"nd");
else if(n%10==3&&n%100!=13)
STR(s,"rd");
else STR(s,"th");
printf("The %d%s humble number is %I64d.\n",n,s,a[n-1]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator