Problem Description
In this problem, we should solve an interesting game. At first, we have an integer n, then we begin to make some funny change. We sum up every digit of the n, then insert it to the tail of the number n, then let the new number be the interesting number n. repeat it for t times. When n=123 and t=3 then we can get 123->1236->123612->12361215.
Sample Input
35 2
35 1
-1 -1
 
Sample Output
Case #1: Yes
Case #2: No

对生成的数%11,余数与下次多增的部分结合,不停求余

(官方:用long long 写不好的会超时,是int的四倍  - -)

#include <iostream>
#include <cstdio> using namespace std;
typedef long long ll; int f(int sum)
{
int i = 0;
while(sum>0)
{
sum /= 10;
i++;
} return i;
} int p(int num)
{
int i = f(num);
int sum = 1;
while(i--)
{
sum *= 10;
} return sum;
} int main()
{
int n, t, tt=1;
while(scanf("%d%d", &n, &t))
{
if(n==-1&&t==-1) break; int sum = 0;
int div = 0;
int temp;
int temps; temp = n;
while(temp>0)
{
sum += (temp%10);
temp /= 10;
} for(int i=0; i<t; i++)
{
div = n % 11; n = div*p(sum) + sum; temp = sum;
temps = 0;
while(temp>0)
{
temps += (temp%10);
temp /= 10;
}
sum += temps; }
if(n%11==0) printf("Case #%d: Yes\n", tt++);
else printf("Case #%d: No\n", tt++);
} return 0; }

  

2015 多校联赛 ——HDU5373(模拟)的更多相关文章

  1. 2015 多校联赛 ——HDU5319(模拟)

    Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Su ...

  2. 2015 多校联赛 ——HDU5402(模拟)

    For each test case, in the first line, you should print the maximum sum. In the next line you should ...

  3. 2015 多校联赛 ——HDU5334(构造)

    Virtual Participation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  4. 2015 多校联赛 ——HDU5302(构造)

    Connect the Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  5. 2015 多校联赛 ——HDU5294(最短路,最小切割)

    Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  6. 2015 多校联赛 ——HDU5325(DFS)

    Crazy Bobo Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Tota ...

  7. 2015 多校联赛 ——HDU5316(线段树)

    Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...

  8. 2015 多校联赛 ——HDU5323(搜索)

    Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  9. 2015 多校联赛 ——HDU5301(技巧)

    Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...

随机推荐

  1. C程序设计-----第0次作业

    C程序设计-----第0次作业- 1.翻阅邹欣老师的关于师生关系博客,并回答下列问题,每个问题的答案不少于500字:(50分)- 1)最理想的师生关系是健身教练和学员的关系,在这种师生关系中你期望获得 ...

  2. JVM笔记7-内存分配与回收策略

    1.对象优先在Eden分配 大多数情况下,对象在新生代Eden区中分配.当Eden区中没有足够空间分配时,虚拟机将发起一次Minor GC.虚拟机提供了-XX:PrintGCDetails 这个收集器 ...

  3. django + nginx + uwsgi + websocket

    最近使用django框架做了一个简单的聊天机器人demo, 开发的过程中使用了django自带的websocket模块,当使用django框架自带的wsgi服务去启动的话,没有什么问题.如果要使用uw ...

  4. CentOS 7 安装Graphite

    Graphite简介 Graphite是一个Python编写的企业级开源监控工具,采用django框架,用来收集服务器所有的即时状态,用户请求信息,Memcached命中率,RabbitMQ消息服务器 ...

  5. 阿里云CentOS部署小笔记

    快毕业了,我用近两周的时间完成了一个nodeJs+Vue-Cli+Mysql的毕业设计,到了部署的时候了. 然而,博主使用Linux的经验有限得很,所以只能自己慢慢地填坑了. 一.准备工作 1)阿里云 ...

  6. python-3.x-基本数据类型

    当前学习版本为: python-3.6-4 代码: """整型 NUMBER""" a = 2 ** 5 b = a + 4 c = a / ...

  7. jquery实现链接的title快速出现

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  8. 如何设置eclipse 右键new的菜单

    如何设置eclipse 右键new的菜单 在使用eclipse进行开发的时候,开发人员一般使用File-new来创建项目或文件,但常常发现,默认右键new选项里很多选项极少会用到,而一些常用的选项又没 ...

  9. 读取properties配置的工具类

    @Service public class AppPropertiesManager implements DisposableBean{ @Value("${shortloan_rate_ ...

  10. Go-GRPC 初体验

    grpc 跟常见的client-server模型相似(doubbo)grpc 编码之前需要准备以下环境: 安装protobuf,grpc的client与server之间消息传递使用的protoc格式消 ...