题目描述

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的更多相关文章

  1. 使用MySQL数据库将汉字转换成拼音的一个C语言小程序

    环境: mysql:mysql-5.1.65 centos:centos 6.5 编译命令: gcc -o chinesetopinyin chinesetopinyin.c -L/usr/lib/m ...

  2. HDU-4089 Activation

    http://acm.hdu.edu.cn/showproblem.php?pid=4089 Activation Time Limit: 20000/10000 MS (Java/Others)   ...

  3. Activation HDU - 4089(概率dp)

    After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. Tomato is a crazy ...

  4. Chinese culture

      文房四宝 笔墨纸砚是中国古代文人书房中必备的宝贝,被称为“文房四宝”.用笔墨书写绘画在 中国可追溯到五千年前.秦(前221---前206)时已用不同硬度的毛和竹管制笔:汉代(前206—公元220) ...

  5. hdu 1788 Chinese remainder theorem again(最小公倍数)

    Problem Description 我知道部分同学最近在看中国剩余定理,就这个定理本身,还是比较简单的: 假设m1,m2,-,mk两两互素,则下面同余方程组: x≡a1(mod m1) x≡a2( ...

  6. 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 ...

  7. PAT1082:Read Number in Chinese

    1082. Read Number in Chinese (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  8. A1082. Read Number in Chinese

    Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese ...

  9. Chinese remainder theorem again(中国剩余定理)

    C - Chinese remainder theorem again Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:% ...

随机推荐

  1. 自动机理论、语言和计算导论 by John E. Hopcroft

    计算理论是计算机应用的基础,理论和应用缺一而不可. ---- 目录 ---- C01 自动机 C02 有穷自动机 C03 正则表达式与正则语言 C04 正则语言的性质 C05 上下文无关文法及上下文无 ...

  2. 一些JavaScript的技巧、秘诀和最佳实践

    文章分享一些JavaScript的技巧.秘诀和最佳实践,除了少数几个外,不管是浏览器的JavaScript引擎,还是服务器端JavaScript解释器,均适用. 本文中的示例代码,通过了在Google ...

  3. firefox 不识别background-position-y / background-position-x

    火狐不识别background-position-y 或background-position-x; 案例: 页面: 背景图: 一列按钮,点击时让当前背景图的background-position-y ...

  4. Bowtie2

    如何使用Bowtie2 相似功能的有: 创建索引 创建索引bowtie2-build使用的命令. -f指定要索引文件后,再给予索引的名称.名称可以连接到任何. bowtie2 build-f refe ...

  5. Linux C 创建目录函数mkdir相关(转-清新居士)

    I.Linux C 创建目录函数mkdir的mode设置问题 函数原型: #include <sys/stat.h> int mkdir(const char *path, mode_t ...

  6. 怎么实时查看mysql当前连接数

    如何实时查看mysql当前连接数? 如何实时查看mysql当前连接数? .查看当前所有连接的详细资料: ./mysqladmin -uadmin -p -h10. processlist .只查看当前 ...

  7. 论文笔记之:Deep Attention Recurrent Q-Network

    Deep Attention Recurrent Q-Network 5vision groups  摘要:本文将 DQN 引入了 Attention 机制,使得学习更具有方向性和指导性.(前段时间做 ...

  8. indexOf ie下的兼容问题

    今天突然发现ie下报错,不支持的属性,原来ie下不支持indexOf. 加入如下代码即可解决. if (!Array.prototype.indexOf){  Array.prototype.inde ...

  9. VS2013的一些常用快捷键

    1.回到上一个光标位置/前进到下一个光标位置 1)回到上一个光标位置:使用组合键“Ctrl + -”: 2)前进到下一个光标位置:“Ctrl + Shift + - ”. 2.复制/剪切/删除整行代码 ...

  10. phonegap文件,目录操作以及网络上传,下载文件(含demo)

    正在做一个跨平台的应用,需要使用phonegap进行文件的一些基本操作. 需求如下:可以选择本地图片,或者从相机选择图片,并进行显示在本地,然后上传到服务器,以及可以从服务器下载图片显示出来,如果本地 ...