题目描述

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. addslashes() 函数和stripslashes()函数

    addslashes() 函数 定义和用法 addslashes() 函数在指定的预定义字符前添加反斜杠. 这些预定义字符是: 单引号 (') 双引号 (") 反斜杠 (\) NULL 语法 ...

  2. <jsp:include>和<%@ include %>的区别

    使用<%@ include %>指令元素只是将页面的内容静态的包含进来,如果被包含的文件中有JSP代码,则会执行该代码,而不管该文件是否为动态文件. <jsp:include> ...

  3. eclipse生成doc文件乱码

    正确生成:在所写项目右击----Export----Java----javadoc---next ----一直next---finish. 乱码时:1)右击----Export----Java---- ...

  4. Apache日志轮替规则

     linux : |/usr/local/sbin/cronolog /web/apache/logs/%Y%m%daccess_log    <IfModule log_config_modu ...

  5. Asm.Def点大兵

    syzoj上的题,收货很多,orz天天学长 原题: Asm.Def奉命组建一支m人的特种作战小队前往圣迭戈.他有n名候选人,可以在其中任意挑选.由于小队中每个人都有独特的作用,所以次序不同的两种选法被 ...

  6. java Map迭代

    //先入先出 public class Test { public static void main(String[] args) { LinkedHashMap<String,Object&g ...

  7. .net framework 4.0 从 GAC 卸载 程序集

    .net framework 4.0 的 GAC 目录: C:\Windows\Microsoft.NET\assembly\GAC_MSIL 要卸载,仍然使用 gacutil 命令,不要带扩展名: ...

  8. nodejs-基本语法

    初识nodejs-基本语法 nodejs是JavaScript的一个在后端的运行环境,关于nodejs的认识,我们可以看上一篇文章<<初识nodejs>>,我们要使用nodej ...

  9. SQL Server DBA日常查询视图_数据库性能视图

    1.获取有关按平均CPU 时间排在最前面的五个查询的信息 total_worker_time/execution_count AS [Avg CPU Time], ), ((CASE qs.state ...

  10. INNO 补丁制作技术, 打开 INNO 补丁制作方法的第一页

    INNO 补丁制作技术, 打开 INNO 补丁制作方法的第一页 作者:xin 日期:2005-09-23 字体大小: 小 中 大   VPatch 在 INNO 中的应用. VPatch 属于专为NS ...