原题链接

1000位大数取余;

秦九昭算法+同余与模算术;

1314 = (((1)*10+3)*10+1)*10+4

( a + b ) % n = ( ( a % n ) + ( b % n ) ) % n

( a - b ) % n = ( ( a % n ) - ( b % n ) + n ) % n       ( ( a % n ) - ( b % n ) 可能小于 n )

a * b % n = ( a % n ) * ( b % n ) % n                     ( ( a % n ) * ( b % n ) 可能会溢出,需要用long long 保存中间结果 )

#include <iostream>
#include <cstring> using namespace std; int main()
{
string s;
while( cin >> s && s != "0" )
{
int i, len = s.size();
int ans = ( s[0]-'0' ) % 11;
for( i=1; i<len; i++ )
ans = ( (ans*10) % 11 + ( s[i]-'0' ) % 11 ) % 11;
if( ans == 0 )
cout << s << " is a multiple of 11." << endl;
else
cout << s << " is not a multiple of 11." << endl; }
return 0;
}

UVA-10929-You can say 11(秦九昭算法+同余与模算术)的更多相关文章

  1. uva 10929 - You can say 11

    #include <cstdio> using namespace std; ]; int main() { while(gets(in)) { ] == ] == ) break; ; ...

  2. 【分享】改变未来的九大算法[pdf][清晰扫描版]

    [下载地址]http://www.colafile.com/file/1179688 图书信息:中文名: 改变未来的九大算法作者: 约翰·麦考密克译者: 管策图书分类: 软件资源格式: PDF版本: ...

  3. 【机器学习实战】第11章 使用 Apriori 算法进行关联分析

    第 11 章 使用 Apriori 算法进行关联分析 关联分析 关联分析是一种在大规模数据集中寻找有趣关系的任务. 这些关系可以有两种形式: 频繁项集(frequent item sets): 经常出 ...

  4. hdoj1013(数根,大数,九余数算法)

    Digital Roots Problem Description The digital root of a positive integer is found by summing the dig ...

  5. cocos2dx基础篇(11) 点九图CCScale9Sprite

    [3.x] (1)去掉"CC" [v3.3] 我们在 ui模块 下实现了一个新的Scale9Sprite类.它的内部实现比之前的Scale9Sprite更为简洁,功能也更为强大. ...

  6. (lintcode全部题目解答之)九章算法之算法班题目全解(附容易犯的错误)

    --------------------------------------------------------------- 本文使用方法:所有题目,只需要把标题输入lintcode就能找到.主要是 ...

  7. c++ LeetCode (初级字符串篇) 九道算法例题代码详解(二)

    原文作者:aircraft 原文链接:https://www.cnblogs.com/DOMLX/p/11089327.html 已经刷了很多篇leetcode题了,不过最近在找c++的实习工作(大佬 ...

  8. 7九章算法强化班全解--------Hadoop跃爷Spark

    ------------------------------------------------------------第七周:Follow up question 1,寻找峰值 寻找峰值 描述 笔记 ...

  9. 九章算法系列(#3 Binary Tree & Divide Conquer)-课堂笔记

    前言 第一天的算法都还没有缓过来,直接就进入了第二天的算法学习.前一天一直在整理Binary Search的笔记,也没有提前预习一下,好在Binary Tree算是自己最熟的地方了吧(LeetCode ...

随机推荐

  1. 存储过程中使用事务和try catch

    一.存储过程中使用事务的简单语法 在存储过程中使用事务时非常重要的,使用数据可以保持数据的关联完整性,在Sql server存储过程中使用事务也很简单,用一个例子来说明它的语法格式: 代码 : Cre ...

  2. sourcetree免注册方法

    step1: https://www.sourcetreeapp.com/官网下载windows版软件 step2: 右键-->以管理员身份运行,便安装成功了 step3: 安装好之后会有这么一 ...

  3. SqlServer——字符串处理函数

    1) ASCII Format:ASCII ( character_expression ) Function:返回表达式最左端字符的ASCII值. eg: select ASCII('abcdef' ...

  4. Spring在代码中获取bean的几种方式(转)

    获取spring中bean的方式总结: 方法一:在初始化时保存ApplicationContext对象 ApplicationContext ac = new FileSystemXmlApplica ...

  5. HAproxy-1.6.3 安装部署

    反向代理优缺点: haproxy反向代理高性能的HTTP,TCP反向代理 nginx:优点:1.web服务器,比较广泛2.工作7层location设置比较复杂基于HTTP(url,cookies,ag ...

  6. Flask框架 之 信号

    Flask框架中的信号基于blinker,其主要就是让开发者可是在flask请求过程中定制一些用户行为. 安装 pip3 install blinker 内置信号 request_started = ...

  7. 组织机构sql

    with cte as (     select vcOrganID, vcParentID, vcOrganName, 0 as lvl from tbOrgan     where vcOrgan ...

  8. 一起做RGB-D SLAM (3)

    第三讲 特征提取与配准 2016.11 更新 把原文的SIFT替换成了ORB,这样你可以在没有nonfree模块下使用本程序了. OpenCV可以使用 apt-get install libopenc ...

  9. BBS项目(2)

    我们实现登录功能的随机验证码的产生 views.py def get_random_color(): return ( # 创建三个0-255的随机数 random.randint(0, 255), ...

  10. mybatis 传参是 list<string> 的注意事项

    <!--付款 批量 修改账单状态--><update id="editbillpayALL" parameterType="java.util.List ...