XidianOJ 1182 Chinese Paladin – Qi’s troubles
题目描述
As we all know, Xiahou Jinxuan (Chinese Paladin 5 Prequel’s protagonist) and Yue Jinzhao
(Chinese Paladin 6’s protagonist) are the most intelligent in Legend series. But who is more NB?
However,it's not enough that only themselves are NB ,they believe that who's wife is more
intelligent,who is more NB.
So they ask their wives to compete. In this case, Xia (Xiahou Jinxuan 's wife) said to Qi
(Yue Jinzhao 's wife) , "Well, I have a problem, if you can answer it, I will admit that your husband is more NB than my husband." Xia is confident, because Qi is only three years old (why is Qi too
young but has a husband, please play Chinese Paladin 6), even if she is a genius, she certainly can't answer it.
Here is the problem: Give you a number n, then constructed a number sequence as following : n, n + 1, n + 2,n + 1, n + 2, n + 3, n + 2, n + 3, n + 4 ...
calculate the sum of the first m items of this number sequence , and outputs the result mod 23333333333, 1 <= n, m <= 10 ^ 12.
Please help Qi to solve the problem, Qi doesn’t want to make Jinzhao ashamed ~
输入
Multiple test cases, please read until EOF
For each test case: One line contains two single integer n, m separated by space
(1 <= n, m <= 10 ^ 12)
输出
For each test case:
One line contains a single integer, the answer.
--正文
前面大段废话,我特意去查了Chinese Paladin,竟然是仙剑www
其实就是三个一循环,很容易找到式子来计算
主要大数的乘法
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define MOD 23333333333
using namespace std;
typedef long long LL;
LL n,m; LL big_multi(LL a,LL b){
LL ans = ;
a = a % MOD;
while (b){
if (b & ) ans = (ans + a) % MOD;
b = b >> ;
a = (a + a) % MOD;
}
return ans;
} int main(){
while (scanf("%lld %lld",&n,&m) != EOF){
LL m3 = m/;
LL mmod3 = m%;
LL res;
if (m3 % == )
res = (big_multi(n,m) + big_multi(*m3/,m3+)) % MOD;
else
res = (big_multi(n,m) + big_multi(*m3,(m3+)/)) % MOD;
if (mmod3 == ){
res = (res + m3) % MOD;
}
if (mmod3 == ){
res = (res + m3 + m3 + ) % MOD;
}
printf("%lld\n",res);
}
return ;
}
XidianOJ 1182 Chinese Paladin – Qi’s troubles的更多相关文章
- 使用MySQL数据库将汉字转换成拼音的一个C语言小程序
环境: mysql:mysql-5.1.65 centos:centos 6.5 编译命令: gcc -o chinesetopinyin chinesetopinyin.c -L/usr/lib/m ...
- HDU-4089 Activation
http://acm.hdu.edu.cn/showproblem.php?pid=4089 Activation Time Limit: 20000/10000 MS (Java/Others) ...
- Activation HDU - 4089(概率dp)
After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. Tomato is a crazy ...
- Chinese culture
文房四宝 笔墨纸砚是中国古代文人书房中必备的宝贝,被称为“文房四宝”.用笔墨书写绘画在 中国可追溯到五千年前.秦(前221---前206)时已用不同硬度的毛和竹管制笔:汉代(前206—公元220) ...
- hdu 1788 Chinese remainder theorem again(最小公倍数)
Problem Description 我知道部分同学最近在看中国剩余定理,就这个定理本身,还是比较简单的: 假设m1,m2,-,mk两两互素,则下面同余方程组: x≡a1(mod m1) x≡a2( ...
- 1082. Read Number in Chinese (25)
题目如下: Given an integer with no more than 9 digits, you are supposed to read it in the traditional Ch ...
- PAT1082:Read Number in Chinese
1082. Read Number in Chinese (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- A1082. Read Number in Chinese
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese ...
- Chinese remainder theorem again(中国剩余定理)
C - Chinese remainder theorem again Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:% ...
随机推荐
- Win10/UWP新特性系列—Launcher实现应用间的通信
UWP中,微软为Windows.System.Launcher启动器新增了很多的功能,以前只能启动App,打开指定扩展名文件,对uri协议的解析,以及当启动的应用没有安装时则会提示前往商店下载等. 如 ...
- 黑马程序员:Java编程_集合
=========== ASP.Net+Android+IOS开发..Net培训.期待与您交流!=========== 面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,就对对象 ...
- Array.prototype.indexOf
arr.indexOf(searchElement[, fromIndex = 0]) Array.prototype.indexOf()
- python的复制,深拷贝和浅拷贝的区别
在python中,对象赋值实际上是对象的引用.当创建一个对象,然后把它赋给另一个变量的时候,python并没有拷贝这个对象,而只是拷贝了这个对象的引用 一般有三种方法, alist=[1,2,3,[& ...
- PAT (Basic Level) Practise:1019. 数字黑洞
[题目链接] 给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字.一直重复这样做,我们很快会停在有“数字黑洞” ...
- 【 D3.js 入门系列 --- 2 】 如何使用数据和选择元素
接着上一讲的内容,这次讨论如何选择元素和使用数据. 现在页面中有三行文字,代码为: <p>Hello World 1</p> <p>Hello World 2 ...
- 关于只针对ie7浏览器的css问题
如代码: .centerDiv .search_k2{ margin-left: 18px; *margin-left: 9px; margin-top: 10px; height: 40px;} 中 ...
- JavaScript 图片的上传前预览(兼容所有浏览器)
功能描述 通过 JavaScript 实现图片的本地预览(无需上传至服务器),兼容所有浏览器(IE6&IE6+.Chrome.Firefox). 实现要点 ● 对于 Chrome.Fire ...
- Logistic回归原理及公式推导[转]
原文见 http://blog.csdn.net/acdreamers/article/details/27365941 Logistic回归为概率型非线性回归模型,是研究二分类观察结果与一些影响因素 ...
- 阻止事件冒泡两种方式:event.stopPropagation();和return false;
jQuery提供了两种方式来阻止事件冒泡. 方式一:event.stopPropagation(); $("#div1").mousedown(function (event) { ...