又改了点,还是budui???????????????
#include <stdio.h>
void intToStr(unsigned int num,char* buf)
{
int i,k = 0;
while(num>0)
{
i = num%10;
num/=10;
buf[k++] = i+48;
}
buf[k] = '\0';
}
int CheckBitNum(unsigned int index,unsigned int* Rad,unsigned int* offSet)
{
unsigned int sum = 10,prevSum = 10,i = 1,rtn = 1,prevI;
while(sum<=index)
{
prevSum = sum;
sum+=9*i;
prevI = i;
i*=10;
rtn++;
}
*offSet = index - prevSum;
if(rtn == (rtn/2)*2)
{
*Rad = prevI+*offSet;
return 1;
}
else
{
*Rad = prevI/10+*offSet/10;
return 0;
}
}
int main()
{
unsigned int index,num,temp,Rad,offSet,rtn;
char buf[50];
while(scanf("%ud",&index) && index)
{
if(index > 9)
{
rtn = CheckBitNum(index,&Rad,&offSet);
num = Rad;
intToStr(num,buf);
if(rtn)
printf("%d%s\n",num,buf);
else
{
temp = offSet%10;
printf("%d%d%s\n",num,temp,buf);
}
}
else
printf("%d\n",index);
}
return 0;
}
----------------解决方案--------------------------------------------------------
ZJU2000的CODE
//2007-05-20 00:36:49 Accepted 2000 C++ 00:00.00 400K
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
double n;
while(scanf(\"%lf\",&n)!=EOF && n){
char buf[20];
int flag=1;
double k=ceil(log10(n/2+1));
double x=pow(10.0,k-1)+n-2*(pow(10.0,k-1)-1)-1;
if(x>(pow(10.0,k)-1)){
x-=9*pow(10,k-1);
flag=0;
}
sprintf(buf,\"%.0lf\",x);
printf(\"%s\",buf);
for(int i=strlen(buf)-1-flag;i>=0;i--){
putchar(buf[i]);
}
putchar('\n');
}
}
----------------解决方案--------------------------------------------------------
ZJU2777的CODE
#include <iostream>
using namespace std;
int array[1001][1001];
int c[1001];
int main()
{
//init
//筛选法
int p,q;
for(p=1;p<=1000;p++){
for(q=1;q<=1000;q++){
array[p][q]=1;
}
}
int cnt(0);
for(p=1;p<=1000;p++){
for(q=1;q<p;q++){
if(array[p][q]==1){
cnt++;
int t=2;
while(t*p<=1000 && t*q<=1000){
array[t*p][t*q]=0;
t++;
}
}
}
c[p]=cnt;
}
//
int N;
scanf(\"%d\",&N);
for(int i=1;i<=N;i++){
int n;
scanf(\"%d\",&n);
printf(\"%d %d %d\n\",i,n,2*c[n]+3);
}
}
----------------解决方案--------------------------------------------------------
回文的位数 1 2 3 4 5 6...
回文个数 9 9 90 90 900 900....
2777我比你好一点.我用的是f(n)=f(n-1)+n组数字判断互质
----------------解决方案--------------------------------------------------------
这一期leeco 做的最好.两个都对了.按照规矩下一期由leeco出题
herbert_1987做的也不错,希望以后继续努力
nuciewth负责给积分
----------------解决方案--------------------------------------------------------
刚看 到.两位到非技术区开帖,偶来发钱.
----------------解决方案--------------------------------------------------------
请问“到非技术区开帖”,是什么意思?
----------------解决方案--------------------------------------------------------
我明白啦!
----------------解决方案--------------------------------------------------------