The shortest problem

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 346    Accepted Submission(s): 167

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.
 
Input
Multiple input.
We have two integer n (0<=n<=104 ) , t(0<=t<=105) in each row.
When n==-1 and t==-1 mean the end of input.
 
Output
For each input , if the final number are divisible by 11, output “Yes”, else output ”No”. without quote.
 
Sample Input
35 2
35 1
-1 -1
 
Sample Output
Case #1: Yes
Case #2: No
 
Source
 
解题:由于能被11整除的数的特点是奇数位与偶数位的和的绝对值可以被11整除,所以,搞一下就可以了
 
 #include <bits/stdc++.h>
using namespace std;
int cur = ,n,m,d[];
int solve(int x) {
int a[] = {};
cur = ;
while(x) {
a[cur^] += x%;
x /= ;
cur ^= ;
}
if(cur&) swap(d[],d[]);
d[] += a[];
d[] += a[];
return d[] + d[];
}
int main() {
int cs = ;
while(scanf("%d%d",&n,&m),(~n) && (~m)) {
d[] = d[] = ;
for(int i = ; i <= m; ++i) n = solve(n);
printf("Case #%d: %s\n",cs++,abs(d[]-d[])%?"No":"Yes");
}
return ;
}

2015 Multi-University Training Contest 7 hdu 5373 The shortest problem的更多相关文章

  1. hdu 5373 The shortest problem(杭电多校赛第七场)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...

  2. 2015 Multi-University Training Contest 7 hdu 5371 Hotaru's problem

    Hotaru's problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. HDU 5373 The shortest problem (数学)

    题意:给定两个数的n和m,有一种操作,把 n 的各位数字加起来放到 n后面形成一个新数n,问重复 m 次所得的数能否整除 11. 析:这个题首先要知道一个规律奇数位的和减去偶数位的和能被11整除的数字 ...

  4. 2019 Multi-University Training Contest 2: 1010 Just Skip The Problem 自闭记

    2019 Multi-University Training Contest 2: 1010 Just Skip The Problem 自闭记 题意 多测.每次给你一个数\(n\),你可以同时问无数 ...

  5. 同余模定理 HDOJ 5373 The shortest problem

    题目传送门 /* 题意:题目讲的很清楚:When n=123 and t=3 then we can get 123->1236->123612->12361215.要求t次操作后, ...

  6. 2015 Multi-University Training Contest 8 hdu 5390 tree

    tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...

  7. 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!

    Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID:  ...

  8. 2015 Multi-University Training Contest 8 hdu 5385 The path

    The path Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 5 ...

  9. 2015 Multi-University Training Contest 3 hdu 5324 Boring Class

    Boring Class Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

随机推荐

  1. applicationContext-solr.xml

    一.动态切换单机和集群 spring-solr 的配置 <!-- 单机版 solrj --> <bean id = "httpSolrServer" class= ...

  2. 简洁又快速地处理集合——Java8 Stream(下)

    上一篇文章我讲解 Stream 流的基本原理,以及它与集合的区别关系,讲了那么多抽象的,本篇文章我们开始实战,讲解流的各个方法以及各种操作 没有看过上篇文章的可以先点击进去学习一下 简洁又快速地处理集 ...

  3. [Beginning SharePoint Designer 2010]Chapter4 发布页面

    本章概要: 1.SharePoint中的Web内容管理 2.SharePoint发布系统的特性 3.SharePoint发布页面的组成 4.母板页 5.如何构建页面布局和他们潜在的内容类型

  4. ios基础-分辨率适配

    (一)分辨率定义 分辨率,是指单位长度内包括的像素点的数量,它的单位通常为像素/英寸(ppi).描写叙述分辨率的单位有:(dpi点每英寸).lpi(线每英寸)和ppi(像素每英寸). (二)ios分辨 ...

  5. Docker推出了Docker云,给大家介绍下哈!

    Docker推出了Docker云,给大家介绍下哈. 收到了Docker官网的邮件邀请,他们推出了Docker云:https://cloud.docker.com 账号信息栏目下有: 云提供商:眼下支持 ...

  6. Pixhawk---基于NSH的Firmware开发与调试

    1 相关知识了解 1.1 Nuttx系统   嵌入式实时操作系统(RTOS). 强调标准兼容和小型封装,具有从8位到32位微控制器环境的高度可扩展性.NuttX 主要遵循 Posix 和 ANSI 标 ...

  7. 王立平--poser

    Poser是Metacreations公司推出的一款lemmaId=234814&ss_c=ssc.citiao.link" style="color:rgb(51,102 ...

  8. PHP中出现Notice: Undefined index的三种解决办法

    前一段做的一个PHP程序在服务器运行正常,被别人拿到本机测试的时候总是出现“Notice: Undefined index:”这样的警告,这只是一个因为PHP版本不同而产生的警告(NOTICE或者WA ...

  9. React中多行文本省略不生效原因

    在普通的前端项目中,在不考虑兼容问题的时候,可以用以下代码实现: overflow : hidden; text-overflow: ellipsis; display: -webkit-box; - ...

  10. roscore不能启动

    通过VNC 在VNC窗口上出入 roscore  得到下面错误信息 ----------------------------------------------------------- proces ...