本题就是给出一个无穷大数,算其能否被11除尽

Description

Your job is, given a positive number N, determine if it is a multiple of eleven.

Input specification

The input is a file such that each line contains a positive number. A line containing the number 0 is the end of the input. The given numbers can contain up to 1000 digits.

Output specification

The output of the program shall indicate, for each input number, if it is a multiple of eleven or not.

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 题解的更多相关文章

  1. Comet OJ - Contest #11 题解&赛后总结

    Solution of Comet OJ - Contest #11 A.eon -Problem designed by Starria- 在模 10 意义下,答案变为最大数的最低位(即原数数位的最 ...

  2. BestCoder Round #11 题解集合

    1001.Alice and Bob 签到题*1,只要x * 2 == n && y * 2 == m就满足条件. var m, n, x, y : int64; begin whil ...

  3. LeetCode(11)题解: Container With Most Water

    https://leetcode.com/problems/container-with-most-water/ 题目: Given n non-negative integers a1, a2, . ...

  4. 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 ...

  5. [NOIP模拟测试11] 题解

    A.string 和河北的一道省选题很像.考场上写的暴力桶排,正解其实就是优化一下这个思路. 开线段树维护字符串中每个字母出现的次数.对于每条询问,区间查询.区间赋值维护即可. 另外,本题卡常严重,正 ...

  6. NOIP2008题解

    传送门 考查题型 二分图 暴力枚举 判断素数 dp T1 传纸条 题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和 ...

  7. 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 ...

  8. HDU 1253 胜利大逃亡

    Problem Description Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会. 魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C ...

  9. Problem 1016 咒文卷轴 优先队列+前缀和+rmq

    题目链接: 题目 Problem 1016 咒文卷轴 Time Limit: 3000 mSec Memory Limit : 131072 KB 问题描述 小Y 是一个魔法师,有一天他获得了一卷神秘 ...

随机推荐

  1. hdu-4418-Time travel-高斯+概率dp

    把N个点先转化为2*N-2个点. 比方说把012345转化成0123454321. 这样,就能够找出随意两两个点之间的关系. 然后依据关系能够得出来一个一元多项式的矩阵. 然后就用高斯消元求出矩阵就可 ...

  2. VSTO 向office文档中插入内容

    原文:VSTO 向office文档中插入内容 Word: Word.Selection sec = ThisAddIn.appWord.Selection;            sec.Insert ...

  3. 【Ruby】Ruby的model学习——Active Record Associations

    在阅读的过程中有不论什么问题,欢迎一起交流 邮箱:1494713801@qq.com    QQ:1494713801 一.怎样定义关联 两个model之间经常会存在关联关系,为了解决这些关联引起的复 ...

  4. iOS_16_开关控制器_modal_代码方法

    最后效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5lbnQ=/font/5a6L5L2T/fontsize/400/fill ...

  5. Java如何检查List<String> 里是否有想要的字符串?

    List<String> test = new ArrayList<String>(); test.add("a"); test.add("b&q ...

  6. 【Android UI】案例03滑动切换效果的实现(ViewPager)

    本例使用ViewPager实现滑动切换的效果.本例涉及的ViewPager.为android.support.v4.view.ViewPager.所以须要在android项目中导入android-su ...

  7. JAVA 保留两位小数的四种方法

    import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; publiccl ...

  8. http://fonts.googleapis.com/css?打开很慢解决方案

    最近, 在写一个demo的时候突然发现加载超级慢, 寻找之下发现了"罪魁祸首", 系引用了http://fonts.googleapis.com/css. 接着在网上看到有网友反映 ...

  9. win7问题解决,凭据管理器和无法访问,不允许一个用户使用一个以上用户名与服务器或共享资源进行多重连接。

    WIN7凭据管理器,如果你用一个帐号远程登录以后在电脑中会记住这个信息,假如你想用另外的帐号,那么就到控制面板-凭据管理器里中进行修改或者删除. 如果你登录以后提示,“无法访问.不允许一个用户使用一个 ...

  10. BIEE11g BI_server Jvm參数调整

    1.找到user_projects\domains\bifoundation_domain\bin文件夹 2.复制startWeblogic.sh为新的文件startAdminWeblogic.sh, ...