51nod 1079 中国剩余定理
来源:互联网 发布:源码基地 编辑:程序博客网 时间:2024/05/21 06:42
题目传送门 : https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1079
一个正整数K,给出K mod 一些质数的结果,求满足条件的最小K,例如, K%2 == 1,K%3 == 2,k%5 == 3, K最小时是23。
此题是一道中国剩余定理的模版题,将被除数和余数分别存在p,m数组中,先令K = m[0],如果K%p[1] != m[1],则让k+=p[0],直到%p[1] == m[1],然后重复操作直到满足所有条件。(只试用于被除数两两互质)
代码如下:
<a target=_blank href="https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1079" style="font-size: 18px; font-weight: bold;">#include <iostream>#include <algorithm>#include <cstring>#include <stdio.h>#include <string>#include <cmath>#define ll long long#define mem(name,value) memset(name,value,sizeof(name))#define mod 1000000007#define PI 3.1415926#define E 2.718281828459using namespace std;const int maxn = 1005;double getlg(double x){ double cnt = 0; while(x > 10){ x /= 10; cnt++; } x += cnt; return x;}int main() { int t; cin >> t; for(int i=0;i<t;i++){ int n; cin >> n; ll res = 0.5 * log10(2.0 * PI * n) + n * log10(n * 1.0 / E) + 1; cout << res << endl; } return 0;}</a><a target=_blank href="https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1079"></a>
0 0
- 51nod 1079 中国剩余定理
- 51nod 1079 中国剩余定理
- 51nod--1079 中国剩余定理
- 51nod 1079 中国剩余定理
- 51nod:1079 中国剩余定理
- 51nod 1079 中国剩余定理
- 51nod 1079 中国剩余定理
- 51nod-1079中国剩余定理
- 51nod 1079 中国剩余定理
- 51nod 1079 中国剩余定理
- 51nod 1079 中国剩余定理
- 51Nod-1079-中国剩余定理
- 51nod-1079 中国剩余定理
- 51Nod-1079-【数学】中国剩余定理
- 51nod 1079 中国剩余定理
- 51Nod 1079:中国剩余定理
- 【51 nod 1079 中国剩余定理】
- 51Nod-1079 中国剩余定理
- Revit开发之带UI的HelloWord
- 异常机制
- java.lang.NoClassDefFoundError: com.baidu.mapapi.SDKInitializer
- Linux系统运维管理之Linux简介
- tcpdump抓包对性能的影响
- 51nod 1079 中国剩余定理
- HDU 5876Sparse Graph (补图上BFS)
- Maven添加jar包
- AdapterView(三)
- windowsXP操作系统的基本功能
- Python里面的字典
- office每次退出时,提示更改会影响共用模板normal
- ArcGIS中任意选点获取栅格点的行列号
- 第一行代码系列第二章——使用隐式Intent