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. 201621123050 《Java程序设计》第7周学习总结

    1. 本周学习总结 1.1 思维导图:Java图形界面总结 2.书面作业 1. GUI中的事件处理 1.1 写出事件处理模型中最重要的几个关键词. 1.事件:用户的操作,例如点击或输入之类的操作 2. ...

  2. CPP 栈 示例

    #include<iostream> #include<stdlib.h> using namespace std; typedef struct node { int dat ...

  3. 15-TypeScript策略模式

    在前面的简单工厂模式中,通常将每个类.接口定义到不同的文件中.在面向对象开发思想中有一个重要的原则就是封装变化点,在实际操作过程中, 通常被调用方的代码不要去更改,而是增加,这是面向对象的开闭原则.在 ...

  4. jquery 表双击某行时,取出某行中各列的数值.

      <script> $(function () { $("tr").dblclick(function () { var txt = $("table tr ...

  5. WPF 自定义ComboBox样式

    一.ComboBox基本样式 ComboBox有两种状态,可编辑和不可编辑状态.通过设置IsEditable属性可以切换控件状态. 先看基本样式效果: 基本样式代码如下: <!--ComboBo ...

  6. httpClient解决post请求重定向的问题

    import com.dadi.saas.util.HTTPUtils; import org.apache.commons.httpclient.Header; import org.apache. ...

  7. 使用 Angular CLI 和 Webpack 分析包尺寸

    使用 Angular CLI 和 Webpack 分析包尺寸 对于 Web app 来说,高性能总是最高优先级,对于 Angular 也不例外.但是随着应用复杂度的不断增长,我们如何才能知道哪些内容打 ...

  8. RTSP连接中断重连的问题

    最近在调查的一个问题. 起因是我司的一款数据链产品,15km数字图传,测试时发现视频画面经常会出现马赛克或卡顿. 图传设置了10Mbps速率,而视频码流是4Mbps,按道理不应该出现这种问题. 经过几 ...

  9. HRBUST1522【单调队列+DP】

    题目:输入一个长度为n的整数序列(A1,A2,--,An),从中找出一段连续的长度不超过m的子序列,使得这个子序列的和最大. #include<stdio.h> #include<s ...

  10. angular-单页面应用程序

    我们都知道angularjs是单一页面应用程序,那什么是单一页面应用程序呢?单一页面应用程序到底有什么好处呢? 下面我们来看一下: 首先我觉得可以把页面的响应模式分成这样大概3个阶段: 1. 最传统的 ...