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:% ...
随机推荐
- 建立开发板与PC机之间的nfs服务器
ARM开发板与PC通过NFS 网络文件系统挂接,很方便文件的移动,也为我们的开发带来了方便.接下来,我就详细的介绍下如何建立ARM与PC机的挂接. 我是用的UBuntu系统. 首先,我们需要在主机上安 ...
- LintCode Search Insert Position
找出指定target的位置(没有此数时为按顺序应当位置). public class Solution { /** * param A : an integer sorted array * para ...
- php开发工具。。
看了好多决定用phpstorm. hahaha PHP还是挺好玩的 但是貌似犯蠢一下,MAC自带有php环境: 我还下了一个XAMPP,不过无所谓啦. 都可以用
- Jmeter--HTTP Cookie管理器
一.什么情况下需要用到Cookie 一般情况下对于HTTP请求的用户登入操作,需要用到Cookie来模拟用户操作,或者对一些业务只有在用户登入之后才能进行操作,比如:常见的场景有购买商品.下单.支付等 ...
- java之main
Java中用户向系统传递参数的三种基本方式 main方法 在Java中,main()方法是Java应用程序的入口方法,也就是说,程序在运行的时候,第一个执行的方法就是main()方法,这个方法和其他的 ...
- 在word里插入图片,并设置图片的格式
由于公司业务需要,需要在生成的word里插入图片(公司印章),仔细想了下,还是在word模板里添加一个书签,然后再该书签的位置插入图片,并设置图片的格式方便些: 代码如下: using System; ...
- Catalan数(数论)
Catalan数 [参考网址]http://www.cnblogs.com/gongxijun/p/3232682.html 记得当时我们队写过一个,差点超时,现在找到了公式,感觉还是挺简单的. 还要 ...
- Android中如何监听GPS开启和关闭
转自 chenming 原文 Android中如何监听GPS开启和关闭 摘要: 本文简单总结了如何监听GPS开关的小技巧 有时需要监听GPS的开关(这种需求并不多见).实现的思路是监听代表 GPS ...
- Cordova从服务器更新客户端的JS文件
思路: 1.主要使用 Cordova的File插件 2.获取需要替换的js文件安装后的路径 3.软件使用js发起ajax请求,后台返回版本号跟客户端版本号对比 4.如果发现需要更新js文件,则用js调 ...
- Electron实战:创建ELectron开发的window应用安装包
前言:研究electron自动更新的时候,在electron的官方文档auto-updater 中,提到了在几个平台mac,Linux,windows下electron 的自动更新方法,其中winds ...