题目链接:https://vjudge.net/contest/156903#problem/B

题意:

有一个递推公式 :

a,b都不是已知的,给出了 x1,x3,x5....

求x2,x4,x6....

枚举所有的 a,b,根据递推公式模运算即可;

 #include <bits/stdc++.h>

 using namespace std;

 int x[];
int t;
const int mod = ; void solve()
{
for(int a=; a<=; a++)
{
for(int b=; b<=; b++)
{
bool ok = true;
for(int i=; i<=*t; i+=)
{
x[i] = (a*x[i-] + b)%mod;
if(i!=*t&&x[i+]!=(a*x[i]+b)%mod)
{
ok = false;
break;
}
}
if(ok) return;
}
}
} int main()
{ while(scanf("%d",&t)!=EOF)
{
for(int i=; i<=*t-; i+=)
{
scanf("%d",&x[i]);
} solve();
for(int i=; i<=*t; i+=)
printf("%d\n",x[i]);
} return ;
}

Uva 12169 不爽的裁判 模运算的更多相关文章

  1. UVa 12169 不爽的裁判

    https://vjudge.net/problem/UVA-12169 题意: 输入T,x1,x2,x3,...,x2T-1,输出x2,x4,...,x2T. 递推公式为xi=(axi-1+b)mo ...

  2. Uva 11582 巨大的斐波那契数 模运算

    题目链接:https://vjudge.net/contest/156903#problem/A 题意:计算 f(a^b)%n 分析: 1.斐波那契数列是 f(i+2) = f(i+1) + f(i) ...

  3. UVA.12169 Disgruntled Judge ( 拓展欧几里得 )

    UVA.12169 Disgruntled Judge ( 拓展欧几里得 ) 题意分析 给出T个数字,x1,x3--x2T-1.并且我们知道这x1,x2,x3,x4--x2T之间满足xi = (a * ...

  4. mysql中的优化, 简单的说了一下垂直分表, 水平分表(有几种模运算),读写分离.

    一.mysql中的优化 where语句的优化 1.尽量避免在 where 子句中对字段进行表达式操作select id from uinfo_jifen where jifen/60 > 100 ...

  5. 数论 : 模运算法则(poj 1152)

    题目:An Easy Problem! 题意:求给出数的最小进制. 思路:暴力WA: discuss中的idea: 给出数ABCD,若存在n 满足 (A* n^3 +B*n^2+C*n^1+D*n^0 ...

  6. poj 3980 取模运算

    取模运算 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10931   Accepted: 6618 Description ...

  7. c++ 模运算

    在数学里,"模运算"也叫"求余运算",用mod来表示模运算. 对于 a mod b 可以表示为 a = q(商)*b(模数) + r(余数),其中q表示商,b表 ...

  8. #数论-模运算#POJ 1150、1284、2115

    1.POJ 1150 The Last Non-zero Digit #质因数分解+模运算分治# 先贴两份题解: http://www.hankcs.com/program/algorithm/poj ...

  9. 二分求幂/快速幂取模运算——root(N,k)

    二分求幂 int getMi(int a,int b) { ; ) { //当二进制位k位为1时,需要累乘a的2^k次方,然后用ans保存 == ) { ans *= a; } a *= a; b / ...

随机推荐

  1. 服务器报nginx: [warn] conflicting server name "blog.xueyi.com" on 0.0.0.0:80, ignored

    nginx: [warn] conflicting server name "blog.xueyi.com" on 0.0.0.0:80, ignored 修改nginx配置参数后 ...

  2. @AutoConfigureAfter不生效 @Configration bean的创建顺序

    https://gooroo.io/GoorooTHINK/Article/17466/Lessons-Learned-Writing-Spring-Boot-Auto-Configurations/ ...

  3. linux下FTP服务搭建(1)

    1.FTP介绍: FTP (File Transfer Protocol,文件传输协议)主要用来文件传输,尤其适用于大文件传输,提供上传下载功能 FTP官方网站:https://filezilla-p ...

  4. vue-cli构建项目添加网站ico的logo

    1.网上找一个把图片改成ico格式的网站,把logo改成ico格式,命名favicon.ico 2.将favicon.ico放入static目录 3.在index.html文件中引入 <link ...

  5. python处理编码问题和JSON格式

    从文件读出数据:默认utf8编码 json.dumps()输出数据:默认unicode编码 json读取(json是种通用的数据传输格式) import ujson as json #for perf ...

  6. 为什么我用gets不行呢?系统无视了我的存在!!!

    梗概:为什么我用gets不行呢?系统无视了我的存在!!!我还没输入东东啊..怎么就提示[请安任意键继续]的?? 原来是缓冲区的问题啊? 一.什么是缓冲区 缓冲区又称为缓存,它是内存空间的一部分.也就是 ...

  7. [转]ASP.NET中JSON的序列化和反序列化

    本文转自:http://www.cnblogs.com/zhaozhan/archive/2011/01/09/1931340.html JSON是专门为浏览器中的网页上运行的JavaScript代码 ...

  8. (转)AIX 用户和组管理

    AIX 用户和组管理 原文:https://www.ibm.com/developerworks/cn/aix/library/au-aixuseradmin/ 管理 IBM AIX 中的用户和组是管 ...

  9. (转)linux应用之test命令详细解析

    linux应用之test命令详细解析 原文:https://www.cnblogs.com/tankblog/p/6160808.html test命令用法. 功能:检查文件和比较值 1)判断表达式 ...

  10. LeetCode 303.区域检索-数组不可变(accumulate()和for循环差异分析)

    给定一个整数数组  nums,求出数组从索引 i 到 j  (i ≤ j) 范围内元素的总和,包含 i,  j 两点. 示例: 给定 nums = [-2, 0, 3, -5, 2, -1],求和函数 ...