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. React.js学习

    React.js学习之环境搭建 1 工欲善其事必先利其器:前端开发工具 1.1 WebStorm和Sublime Text Sublime Text:作为代码编辑器,Sublime Text的优点如下 ...

  2. Windows Phone 8初学者开发的翻译终于过半

    从2013年7月19日开始,到2013年12月9日,一共花了143天时间完成了18篇Windows Phone 8初学者开发的翻译,还剩下17篇文章需要翻译,看到了完成的希望! I love Wind ...

  3. 用 Eclipse 下载 Git 仓库中代码

    1. 安装 Git 插件 可以按照 通过Eclipse从subversion站点下载源码 中的方法安装,也可以在 Eclipse Marketplace 中搜索 EGit 进行安装(Help --&g ...

  4. 反应堆Reactor

    mvn -h 可以看到很多命令及其用途:-am --also-make 同时构建所列模块的依赖模块:-amd -also-make-dependents 同时构建依赖于所列模块的模块:-pl --pr ...

  5. webform中几个常用的控件

    一,简单控件 1,Lable——标签:在网页中呈现出来的时候会变成span标签 属性:Text——标签上的文字  BackColor,ForeColor——背景色,前景色 Font——字体 Bold- ...

  6. 测试markdown语法

    测试使用markdown 这是无序列表 空调 洗衣机 电脑 这是有序列表 西瓜 哈密瓜 火龙果 下划线bingo 测试 斜体好丑 粗体很赞 测试插入代码 $(document).ready(funct ...

  7. Visual Studio2013创建、公布监控Windows Azure网站

    原文 Visual Studio2013创建.公布监控Windows Azure网站 随着Visual Studio 2013的发布,现在我们可以在Visual Studio内部实现Windows A ...

  8. awakeFromNib小总结

    awakeFromNib 在使用IB的时候才会涉及到此方法的使用,当.nib文件被载入的时候,会发送一个awakeFromNib的消息到.nib文件里的每一个对象,每一个对象都能够定义自己的awake ...

  9. Object-c @property的用法

    property是一种代码生成机制,可以生成不同类型的getter/setter函数,特别是假设你想要用点(.)操作符号来存取变量的话,你就能必须使用property. 怎样使用? 使用方法如:@pr ...

  10. Android的StrictMode

    转自:http://blog.csdn.net/tonyfield/article/details/8238251 Android 2.3提供一个称为严苛模式(StrictMode)的调试特性,Goo ...