COJ 1102 - You Can Say 11 题解
本题就是给出一个无穷大数,算其能否被11除尽
Description
Input specification
Output specification
Sample input
112233
30800
2937
323455693
5038297
112234
0
Sample output
112233 is a multiple of 11.
30800 is a multiple of 11.
2937 is a multiple of 11.
323455693 is a multiple of 11.
5038297 is a multiple of 11.
112234 is not a multiple of 11.
使用string模拟除法就能够了。
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std; bool divEleven(string s)
{
int carry = 0;
for (int i = 0; i < s.size(); i++)
{
int d = carry * 10 + s[i] - '0';
carry = d % 11;
}
if (carry) return false;
return true;
} void Eleven()
{
string S;
while (cin>>S && "0" != S)
{
if (divEleven(S)) cout<<S<<" is a multiple of 11.\n";
else cout<<S<<" is not a multiple of 11.\n";
}
}
COJ 1102 - You Can Say 11 题解的更多相关文章
- Comet OJ - Contest #11 题解&赛后总结
Solution of Comet OJ - Contest #11 A.eon -Problem designed by Starria- 在模 10 意义下,答案变为最大数的最低位(即原数数位的最 ...
- BestCoder Round #11 题解集合
1001.Alice and Bob 签到题*1,只要x * 2 == n && y * 2 == m就满足条件. var m, n, x, y : int64; begin whil ...
- LeetCode(11)题解: Container With Most Water
https://leetcode.com/problems/container-with-most-water/ 题目: Given n non-negative integers a1, a2, . ...
- Comet OJ - Contest #11题解
传送门 \(A\) 咕咕咕 const int N=1e6+5; char s[N],t[N];int n,res; inline bool cmp(const int &x,const in ...
- [NOIP模拟测试11] 题解
A.string 和河北的一道省选题很像.考场上写的暴力桶排,正解其实就是优化一下这个思路. 开线段树维护字符串中每个字母出现的次数.对于每条询问,区间查询.区间赋值维护即可. 另外,本题卡常严重,正 ...
- NOIP2008题解
传送门 考查题型 二分图 暴力枚举 判断素数 dp T1 传纸条 题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和 ...
- Good Bye 2015 B. New Year and Old Property —— dfs 数学
题目链接:http://codeforces.com/problemset/problem/611/B B. New Year and Old Property time limit per test ...
- HDU 1253 胜利大逃亡
Problem Description Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会. 魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C ...
- Problem 1016 咒文卷轴 优先队列+前缀和+rmq
题目链接: 题目 Problem 1016 咒文卷轴 Time Limit: 3000 mSec Memory Limit : 131072 KB 问题描述 小Y 是一个魔法师,有一天他获得了一卷神秘 ...
随机推荐
- C++&&Mysql&&codeblocks
#include <iostream> #include <stdio.h> #include <winsock2.h> #include <mysql.h& ...
- hdu4289(最小割)
传送门:Control 题意:有n个城市,有个小偷想从其中一个城市逃到另一个城市,警察想要堵截这个小偷,知道了在每个城市堵截的成本,问如何安排在哪些城市堵截可以使得小偷一定会被抓住,而且成本最低. 分 ...
- Android getTopActivity的方法
使用例如以下方法能够获得top activity 的name public String getTopActivityPackageName(Context context) { String top ...
- linux LNMP自动安装脚本
#!/bin/bashsoft_dir="/home/soft"config_dir="/home/config"httpd="httpd-2.0.5 ...
- 〖Groovy〗语言使用贴士(Tips)(转)
[Groovy]是一门运行在[JVM]之上的动态语言.由[James Strachan]和[Bob McWhirter]于2003年启动开发,之后于2004年3月成为[JSR 241](Java Sp ...
- POJ 2524 :Ubiquitous Religions
id=2524">Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 231 ...
- 2012Android开发热门资料(110个)
下载中心完整附件下载地址:http://down.51cto.com/data/412494 附件内容部分预览: 专题推荐: Android控:平板电脑HD精品游戏软件合集(共32个) http:// ...
- 搜索树SVN的树的时候遇到的乱码问题
public void listDirectoryNode(SVNRepository repository, String dirUrl, FileNode node) { String curre ...
- iis 隐藏 banner
去微软官网下载这个补丁 http://www.microsoft.com/en-us/search/DownloadResults.aspx?q=urlscan+3.1 2. 安装urlscan_ ...
- hibernate 一对多,多对一,多对多实体映射完美解决方案(再也不会糊涂了,哈哈)