原题链接

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. 477. Total Hamming Distance总的二进制距离

    [抄题]: The Hamming distance between two integers is the number of positions at which the correspondin ...

  2. 从计算框架MapReduce看Hadoop1.0和2.0的区别

    一.1.0版本 主要由两部分组成:编程模型和运行时环境. 编程模型为用户提供易用的编程接口,用户只需编写串行程序实现函数来实现一个分布式程序,其他如节点间的通信.节点失效,数据切分等,则由运行时环境完 ...

  3. shiro 权限集成Ehcache 配置 学习记录(二)

    1.加入依赖 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-eh ...

  4. XML(子节点序列化反序列对象)读写

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  5. 拖拽demo--兼容--全局捕获

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. STL中 map 和 multimap

    1. 所在头文件<map>. 命名空间std, 声明如下: namespace std{ template <class Key,class T, class Compare = l ...

  7. PLSA算法(转)

    文章分类:综合技术 1. 引子 Bag-of-Words 模型是NLP和IR领域中的一个基本假设.在这个模型中,一个文档(document)被表示为一组单词(word/term)的无序组合,而忽略了语 ...

  8. 网站如何集成Facebook和Twitter第三方登录

    最近公司要求做海外的第三方登录:目前只做了Facebook和Twitter;国内百度到的信息太少VPN FQ百度+Google了很久终于弄好了.但是做第三方登录基本上都有个特点就是引入必须的js,设置 ...

  9. centos7部署JavaWeb项目

    centos7部署JavaWeb项目共有三步 1.配置java环境 2.配置tomcat环境. 3.部署JavaWeb项目 一.配置java环境 1.1安装java 参考我的另一篇博文:https:/ ...

  10. ScreenCapture-drupal 7.34-ckeditor4x整合教程

    1.1. drupal 7x-ckeditor4x 插件下载:Drupal 7x, 1.1.1. 安装ckeditor4x 下载插件 说明:下载并解压 CKEditor4x插件:https://yun ...