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:% ...
随机推荐
- 防止apache下面直接输入目录访问文件
有些项目链接会暴露服务器上面的文件地址,如何访问文件被访问呢 方法一: 在项目入口文件下面新加一个.htaccess文件(apache开启重写模式才会加载这个文件,否则这个文件配置不会生效) 文件中加 ...
- HTML的总结
一.Html简介 HTML 是一种标记语言 忽略大小写,语法宽松 使用 HTML 标记和元素,可以: 控制页面和内容的外观 发布联机文档 使 ...
- Java 设计一个贷款计算器 简易
import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.*; publi ...
- R读取数据的错误
使用R读取数据的时候遇到这种错误: invalid multibyte string at '<fd>' 解决方法就是: tbl <- read.delim("dir/fi ...
- Thrift 个人实战--Thrift RPC服务框架日志的优化
前言: Thrift作为Facebook开源的RPC框架, 通过IDL中间语言, 并借助代码生成引擎生成各种主流语言的rpc框架服务端/客户端代码. 不过Thrift的实现, 简单使用离实际生产环境还 ...
- Ubuntu中开启MySQL远程访问功能,并将另一个数据库服务器中的数据迁移到新的服务器中
一.开启MyS远程访问功能 1.进入服务器输入netstat -an | grep 3306确认3306是否对外开放,MySQL默认状态下是不对外开放访问功能的.输入以上命令之后如果端口没有被开放就会 ...
- gdb使用心得
启用调试gdb gdb 路径到prog_1dray 然后就直接进去gdb了 进去后输入r *.par 参数文件就行了 暂时学到这,用到这!日后再学习更新
- Anchor 对象
更改一个链接的文本.URL 以及target<html><head><script type="text/javascript"> functi ...
- Hadoop 2.6.4单节点集群配置
1.安装配置步骤 # wget http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.rpm # rpm -i ...
- apache 配置多个虚拟主机,不同的端口
1.在httpd.conf添加多个端口,如下 Listen 80Listen 8080 2.开启Include conf/extra/httpd-vhosts.conf 3.具体代码如下 <Vi ...