UVA 756 - Biorhythms(数论)
来源:互联网 发布:减肥前后对比知乎 编辑:程序博客网 时间:2024/05/16 15:51
756 - Biorhythms
题目链接
基本就是裸的中国剩余定理。
代码:
#include <stdio.h>#include <string.h>const int M = 23 * 28 * 33;const int m[3] = {23, 28, 33};int p[3], d;int gcd(int a, int b, int &x, int &y) {if (!b) {x = 1; y = 0; return a;}int d = gcd(b, a % b, y, x);y -= a / b * x;return d;}int main() {int cas = 0;while (~scanf("%d%d%d%d", &p[0], &p[1], &p[2], &d)) {if (p[0] < 0 && p[1] < 0 && p[2] < 0 && d < 0) break; int ans = 0; for (int i = 0; i < 3; i++) {int x, y, w = M / m[i];gcd(m[i], w, x, y);ans = (ans + p[i] % m[i] * w * y) % M; } ans -= d; if (ans <= 0) ans += M; printf("Case %d: the next triple peak occurs in %d days.\n", ++cas, ans); }return 0;}
1 0
- UVA 756 - Biorhythms(数论)
- UVA, 756 Biorhythms
- uva 756—— Biorhythms
- POJ--1006--Biorhythms【数论】
- Biorhythms(数论)
- uva 756 - Biorhythms(中国剩余定理)
- ACM 数论 hdu 1370 Biorhythms
- POJ 1006 Biorhythms 数论-(孙子定理)
- Biorhythms
- Biorhythms
- Biorhythms
- Biorhythms
- Biorhythms
- Biorhythms
- Biorhythms
- Biorhythms
- Biorhythms
- Biorhythms
- opencv-阈值化处理
- CDN总结之四
- 用cmd进入MySql解决MySql窗口不够大的问题
- Bin Packing - UVALive 3503 贪心
- LINUX总结第8篇:Ubuntu下搭建java开发环境
- UVA 756 - Biorhythms(数论)
- myeclipse导入项目项目名上有个红叉,但代码没有报错
- Qt学习之路(1):前言
- android网上服装购物系统
- bnu 34981 A Matrix(构造)
- 【数字图像处理之(一)】数字图像处理与相关领域概述
- 黑马程序员--循环语句while for
- Qt学习之路(2):Hello, world!
- 5.qemu-kvm 网络配置