problem 1278
别想太多,暴力就能AC。不过要注意循环不一定从种子数据开始。(就算判重用循环做也可以过的。)
Accepted | 1278 | C++ | 00:00.00 | 396K |
#include <string.h>
#include <stdlib.h>
void solve(int Z,int I,int M,int L)
{
char* check = (char*)malloc(M * sizeof(char ));
memset(check,0,M * sizeof(char ));
int cnt = 0 ;
while(check[L] == 0 )
{
check[L] = ++ cnt;
L = (Z * L + I) % M;
}
printf("%d/n",cnt - check[L] + 1 );
free(check);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1278.txt","r" ,stdin);
#endif
int Z,I,M,L;
int t = 0 ;
while(scanf("%d%d%d%d",&Z,&I,&M,&L) != EOF && !(Z == 0 && I == 0 && M == 0 && L == 0 ))
{
printf("Case %d: ",++ t);
solve(Z,I,M,L);
}
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0 ;
}
problem 1278相关推荐
- LightOJ 1278 - Sum of Consecutive Integers 分解奇因子 + 思维
http://www.lightoj.com/volume_showproblem.php?problem=1278 题意:问一个数n能表示成几种连续整数相加的形式 如6=1+2+3,1种. 思路:先 ...
- B. A and B
链接:https://codeforces.com/problemset/problem/1278/B You are given two integers aa and bb. You can pe ...
- Codeforces 1278 B. A and B (思维题)
题目链接:https://codeforces.com/contest/1278/problem/B 题目大意: 给定两个整数a,b,现在进行以下的操作: 第一次操作,从a,b两个数中选择一个+1. ...
- Codeforces 1278 D.Segment Tree(排序+set)
题目链接:https://codeforces.com/contest/1278/problem/D 题目大意: 给定一堆线段[li,ri],每个线段的端点都不一样,如果两个线段相交,那么他们必须是有 ...
- linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.
所有的base 都要取消注释 mirrorlist 加上注释 另外所有的enable都要设为零 目录 今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现y ...
- A + B Problem
1001: A + B Problem Description 计算 A + B. Input 多组测试数据,每组测试数据占一行,包括2个整数. Output 在一行中输出结果. Sample Inp ...
- Error:(49, 1) A problem occurred evaluating project ':guideview'. Could not read script 'https://r
出现问题如下: Error:(49, 1) A problem occurred evaluating project ':guideview'. > Could not read script ...
- #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)
题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...
- ADPRL - 近似动态规划和强化学习 - Note 3 - Stochastic Infinite Horizon Problem
Stochastic Infinite Horizon Problem 3.Stochastic Infinite Horizon Problem 定义3.1 无限范围的马尔可夫决策过程 (Marko ...
最新文章
- C++高精度运算类bign (重载操作符)
- HTTP基础认证Basic Authentication
- Oracle Dababase_buffer_cache数据库高速缓存组织结构剖析
- 主模式和野蛮模式_网络野蛮行为的含混性和观念
- opencv,用摄像头识别贴片元件的定位和元件的角度(转载)
- JDK1.8 JVM元数据区取代了永久代,元数据空间并不在虚拟机中,而是使用本地内存
- 分享一套阿里高级Java面试题,要去阿里的先过这些题。
- C#使用StreamReader类读取文件文件
- python基础-软件目录开发规范
- HTML5与HTML4区别
- android preference-headers 字体颜色,如何修改CheckBoxPreference 中title ,summary字体的颜色...
- 基于51单片机数码管显示
- HTML——表格合并
- 我靠海外抖音搬运视频赚到了人生第一桶金:这个风口行业,真的很赚钱
- java8的sorted,Java8排序stream.sorted()
- DOM基础详细 包含多个案例
- php artisan passport,Laravel Passport
- 撩妹攻略话术恋爱小程序源码分享
- 搞定机器学习面试,这些是基础!(下载PDF)
- 洛谷3258 松鼠的新家