J - Palindrome Numbers

Time
Limit:
3000MS     Memory Limit:0KB     64bit
IO Format:
%lld & %llu

 
 
 
WA了一版面,我也是醉了,就由于一个编译环境不同。。

。。。。

 
说多了都是泪。
 
 
转载请注明出处:寻找&星空の孩子


 
#include<stdio.h>
#define LL long long
#define MM 2000000000
LL num[25]= {0};
LL ppow(LL x,LL y)
{
LL tp=1;
while(y--)
{
tp*=x;
}
return tp;
} void init()
{
LL tp=9,i;
for(i=1;;)
{
num[i]=num[i-1]+tp;
i++;//同行有多个i要处理的时候i,不要把i++放里面,由于变异环境不同。运算顺序不同,可能会wa
num[i]=num[i-1]+tp;
i++;
tp=tp*10;
if(num[i-1]>=MM)break;
} /* for(int i=1;i<21;i++)
{
LL p=(i+1)/2-1;
num[i]=num[i-1]+9*ppow(10,p);
// printf("%lld\n",num[i]);
}
// printf("%lld\n",num[0]);*/
} int main()
{
init();
LL n;
LL a[20];
while(scanf("%lld",&n),n)
{
int len=0;
for(int i=1; i<=20; i++)
{
if(n<=num[i])
{
len=i;
break;
}
}
// printf("len=%d\n",len);
LL m=n-num[len-1];
int l=(len+1)/2;
// printf("m=%lld\tl=%d\n",m,l);
LL ans=ppow(10,l-1)+m-1;
// printf("ans=%lld\tppow=%lld\n",ans,ppow(10,l-1));
printf("%lld",ans);
if(len&1) ans/=10;
while(ans)
{
printf("%lld",ans%10);
ans/=10;
}
printf("\n");
}
return 0;
}

Palindrome Numbers(LA2889)第n个回文数是?的更多相关文章

  1. POJ 2402 Palindrome Numbers(LA 2889) 回文数

    POJ:http://poj.org/problem?id=2402 LA:https://icpcarchive.ecs.baylor.edu/index.php?option=com_online ...

  2. POJ2402 Palindrome Numbers 回文数

    题目链接: http://poj.org/problem?id=2402 题目大意就是让你找到第n个回文数是什么. 第一个思路当然是一个一个地构造回文数直到找到第n个回文数为止(也许大部分人一开始都是 ...

  3. POJ2402 Palindrome Numbers第K个回文数——找规律

    问题 给一个数k,给出第k个回文数  链接 题解 打表找规律,详见https://www.cnblogs.com/lfri/p/10459982.html,差别仅在于这里从1数起. AC代码 #inc ...

  4. leetcode 9 Palindrome Number 回文数

    Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...

  5. [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product

    Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...

  6. leetcode-479-Largest Palindrome Product(找到两个乘数相乘得到的最大的回文数)

    题目描述: Find the largest palindrome made from the product of two n-digit numbers. Since the result cou ...

  7. 有趣的数-回文数(Palindrome number)

    文章转自http://blog.163.com/hljmdjlln@126/blog/static/5473620620120412525181/ 做LC上的题"Palindrome num ...

  8. leetcode4 Valid Palindrome回文数

    Valid Palindrome回文数 whowhoha@outlook.com Question: Given a string, determine if it is a palindrome, ...

  9. Palindrome 回文数

    回文数,从前到后,从后到前都一样 把数字转成字符串来处理 package com.rust.cal; public class Palindrome { public static boolean i ...

  10. Leetcode 3——Palindrome Number(回文数)

    Problem: Determine whether an integer is a palindrome. Do this without extra space. 简单的回文数,大一肯定有要求写过 ...

随机推荐

  1. Oracle 当前时间加减

     当我们用 select sysdate+number from dual ;我们得到的是,当前的时间加上number天后的时间.从这里我们也可以看出,使用这种方式进行时间计算的时候,计算的单位是天, ...

  2. MPMoviePlayerController导致statusBar消失,导致内存泄露leak

    1.MPMoviePlayerController使statusBar消失 同事写项目时,运行程序总导致statusBar状态条消失,然后就是界面会上移20个像素,导致最下面空白界面,找原因一直不知道 ...

  3. ASP.NET - 匹配标签中的内容

    string str = @"<td>Csdn</td>\r\n<td>V1.0</td>\r\n<td>2014-10-23&l ...

  4. linux下编译qt5.6.0静态库——configure配置(超详细,有每一个模块的说明)(乌合之众)

    linux下编译qt5.6.0静态库 linux下编译qt5.6.0静态库 configure生成makefile 安装选项 Configure选项 第三方库: 附加选项: QNX/Blackberr ...

  5. 拷贝构造函数和const成员函数

    实验原因 说明如何使用const描述保护类数据不会意外修改. 编译环境 vc6sp6 + win7x64 工程下载 copyConstruction_constMemberFunction.zip   ...

  6. 基于visual Studio2013解决面试题之0609寻找链表公共节点

     题目

  7. Basic4android:多功能的Android应用软件快速开发平台

    Basic4android 是目前最简单.最强大的Android平台快速应用开发工具. ( "Basic4android is the simplest and most powerful ...

  8. Python中列表的常用操作

    只整理重要常用的操作: append():尾部追加元素,参数只能为一个. extend():用列表扩展列表,参数为列表. insert():在指定位置插入元素,第一个参数为插入位置,第二个为参数为插入 ...

  9. <转载>如何解决子级用float浮动父级div高度不能自适应的问题

    转载:http://www.kwstu.com/ArticleView/divcss_2013101582430202 解决子级对象使用css float浮动 而父级div不能自适应高度,不能被父级内 ...

  10. C 语言资源大全中文版

    C 语言资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-c 是 koz.ross 发起维护的 C 语言资源列表,内容包括了: ...