题目地址:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 Knowledge Point: 同余定理:两个整数a.b,若它们除以整数m所得的余数相等,则称a与b对模m同余或a同余于b模m.记作 a≡b(mod m): 加法运用: (a + b) % m = (a % m + b % m) % m 乘法运用: (a * b) % m = ((a % m) * (b % m)) % m 高精度取模: 一个高精度数对一个数取余,可以把高精…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤10 9). Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016 2016 100000…
2016 Problem Description: 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1≤a≤n,1≤b≤m; a×b 是 2016 的倍数. Input: 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤109). Output: 对于每组数据,输出一个整数表示满足条件的数量. Sample Input: 32 63 2016 2016 1000000000 1000000000 Sample Output: 1 30576…
1803: 2016 Submit Page   Summary   Time Limit: 5 Sec     Memory Limit: 128 Mb     Submitted: 1416     Solved: 815 Description    给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:       1. 1≤a≤n,1≤b≤m;   2. a×b 是 2016 的倍数.   Input   输入包含不超过 30 组数据.   每组数据包含两个整数 n,…
湖南省第十二届大学生计算机程序设计竞赛$A$题 枚举. 处理一下$\% 2016$之后的数分别有几个,然后$2016*2016$枚举一下统计方案数就可以了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vec…
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803 题目大意: 给定n,m(n,m<=109)1<=i<=n,1<=j<=m,求i*j%2016=0的方案数. 题目思路: [模拟][数学] 按照%2016的余数分类.每增加一个2016就又多一种方案.统计是2016的几倍,根据余数分类.最后枚举i,j的余数即可求解. // //by coolxxx //#include<bits/stdc++.h>…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 Description  给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤109). Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016…
原题链接 http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 Description Bobo has a balanced parenthesis sequence P=p1 p2…pn of length n and q questions. The i-th question is whether P remains balanced after pai and pbi  swapped. Note that questions ar…
2016湖南省赛----A 2016 (同余定理) Description  给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤10 9). Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016 2016 1000000000 1000000000 Sample…
1803: 2016 Description  给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:   1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤109).   Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016 2016 1000000000 1000000000 Sample Output 1 30…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1214 题意很好懂,同余定理的运用,要是A数被B数整除,那么A%B等于0.而A很大,那我就把A的每一位拆开,比如A是2341,那么2341=2000+300+40+1,然后你懂的... #include <iostream> #include <cstdio> #include <cstring> using namespace std; ]; int mai…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5930    Accepted Submission(s): 4146 Problem Description As we know, Big Number is always troublesome. But it's really important in our…
此题往后推几步就可找到规律,从1开始,答案分别是1,2,4,8,16.... 这样就可以知道,题目的目的是求2^n%Mod的结果.....此时想,应该会想到快速幂...然后接着会发现,由于n的值过大,很容易就会T掉... 所以这个时候就想到找规律...试试就可以知道,1e9+6的时候是循环节... 然后用同余定理,把余数求出来就可以了... #include<iostream> #include<string> #include<string.h> #include&l…
题目如下: Description 请求N!(N<=10000),输出结果对10007取余输入每行一个整数n,遇到-1结束.输出每行一个整数,为对应n的运算结果.   Sample Input 1 2 -1   Sample Output 1 2 分析思路: 题目思路很简单,每读取一个输入就输出对应输入的阶乘.直到遇到输入为-1时结束程序. 核心问题: 这个题目在写的时候遇到的难点是N!实在是太大了,根本储存不下,之后试了long long int 也还是只能储存到20几就会溢出.解决这个问题的…
The Embarrassed Cryptographer Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11978   Accepted: 3194 Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of…
思路:d(i,j)表示以i开头,长度为j的K好数的个数,转移方程就是 for(int u = 0; u < k; ++u) { int x = abs(i - u); if(x == 1) continue; //相邻的数字相同 dp[i][j] += dp[u][j-1]; } 还有就是可能答案很大一定要一边求解一边求余. 同余定理用起来,内存可用滚动数组优化. AC代码 #include <cstdio> #include <cmath> #include <alg…
第十二届 GOPS 全球运维大会深圳站 会议召开时间:2019年4月12日-13日 会议召开地点:深圳圣淘沙酒店(翡翠店) 会议主办单位:高效运维社区 票务合作伙伴:活动家 会议报名地址:https://www.huodongjia.com/event-1887291715.html 大会为期2天,侧重方向是 AIOps.运维自动化和 DevOps.目前已经有全国各地大公司组团前来参加. 此外还有一些特色专场如:AIOps 场景实践专场.DevOps 最佳实践专场.DevOps 标准认证企业案例…
青蛙的约会 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions:132162   Accepted: 29199 Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置.不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能…
A/B Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10383    Accepted Submission(s): 8302 Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1).   Input 数据的第一行是…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4594    Accepted Submission(s): 3175 Problem Description As we know, Big Number is always troublesome. But it's really important in ou…
id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS   Memory Limit: 32768K Total Submissions: 6164   Accepted: 1339 Description a program that, given a natural number N between 0 and 4999 (inclusively), and M distinct decimal digit…
D. Notepad time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Nick is attracted by everything unconventional. He doesn't like decimal number system any more, and he decided to study other numb…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1104 在做这道题目一定要对同余定理有足够的了解,所以对这道题目对同余定理进行总结 首先要明白计算机里的取余计算和数学里的不一样的,计算机里的负数取余可以是负数的.例如-1%11=-1 而数学里的取余是-1%11=10 同余定理: 若a对d取余,和b对d取余的结果是相等的,那么称a,b对d是同余的.记作a≡b(mod d);这是数学里的定义. 下面看同余定理的几个性质: 1,a≡a(mod d) 数字…
J - Judge   Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submit Status Practice HPU 1194 Description Ocean从影视城回来后,吃了一个放大果实(恶魔果实的一种),高呼:“海贼王に.俺はなる!” Ocean每使用一次能力,就可以将一个物品的价值放大$x$倍(原价值乘以$x$). 但是哪有这么好的事情? 物品的价值是有限度的,姑且认为物品…
Description Edward  得到了一个长度为  N  的整数序列,他想找出这里面有多少个“幸运的”连续子序列.一个连续子序列被称为“幸运的”,当且仅当该子序列内的整数之和恰好是  K  的整数倍数.他请求你写一个程序来计算他喜欢的连续子序列个数. Input 输入第一行是一个整数  T,表示有  T  组数据.每组数据第一行是两个整数  N (1 <= N <= 10^6), K (1 <= K <= 10^9).接下来的一行包含  N  个整数  Ai (|Ai| &…
Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c. Input Input starts with an integer T (≤ 525), denot…
1803: 2016 Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 565  Solved: 364[Submit][Status][Web Board] Description  给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤109). Output 对于每组数据…
同余问题 基本定理: 若a,b,c,d是整数,m是正整数, a = b(mod m), c = d(mod m) a+c = b+c(mod m) ac = bc(mod m) ax+cy = bx+dy(mod m) -同余式可以相加 ac = bd(mod m) -同余式可以相乘 a^n = b^n(mod m) f(a) = f(b)(mod m) if a = b(mod m) and d|m then a = b(mod d) eg: 320 = 20(mod 100) and d =…
1433 0和5 题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题  收藏  关注 小K手中有n张牌,每张牌上有一个一位数的数,这个字数不是0就是5.小K从这些牌在抽出任意张(不能抽0张),排成一行这样就组成了一个数.使得这个数尽可能大,而且可以被90整除. 注意: 1.这个数没有前导0, 2.小K不需要使用所有的牌. Input 每个测试数据输入共2行. 第一行给出一个n,表示n张牌.(1<=n<=1000) 第二行给出n个…
The Embarrassed Cryptographer Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15767   Accepted: 4337 Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of…