B.Petr and a Combination Lock】的更多相关文章

https://codeforces.com/contest/1097/problem/A Petr and a Combination Lock time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petr has just bought a new car. He's just arrived at the most known…
Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of 360360 degrees and a pointer whi…
Content 有一个锁,它只有指针再次指到 \(0\) 刻度处才可以开锁(起始状态如图所示,一圈 \(360\) 度). 以下给出 \(n\) 个操作及每次转动度数,如果可以通过逆时针或顺时针再次转到 \(0\) 度输出 YES,否则输出 NO. 数据范围:\(1\leqslant n\leqslant 15\),\(1\leqslant a_i\leqslant 180\). Solution 不知道为什么 19 年 4 月就做了这题,现在看到这题想写篇题解,于是就有了这篇题解( 我们一看到…
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a Microsoft interviewer is in the room though the door is locked. There is a combination lock on the door. There are N rotators on the lock, each consists o…
传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a Microsoft interviewer is in the room though the door is locked. There is a combination lock on the door. There are N rotators on the lock, each consis…
题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN], t[MAXN]; int main(void) //Codeforces Round #301 (Div…
A. Combination Lock Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/problem/A Description Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treas…
Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a Microsoft interviewer is in the room though the door is locked. There is a combination lock on the door. There are N rotators on the lock…
A :Combination Lock 题意就是有一个密码箱,密码是n位数,现在有一个当前箱子上显示密码A和正确密码B,求有A到B一共至少需要滚动几次: 简单循环:…
题目1 : Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a Microsoft interviewer is in the room though the door is locked. There is a combination lock on the door. There are N rotators on th…
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and…
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=3104 Problem Description A combination lock consists of a circular dial, which can be turned (clockwise or counterclockwise) and is embedded into the "fixed" part of the lock. The dial has N evenly…
P2693 [USACO1.3]号码锁 Combination Lock 题目描述 农夫约翰的奶牛不停地从他的农场中逃出来,导致了很多损害.为了防止它们再逃出来,他买了一只很大的号码锁以防止奶牛们打开牧场的门. 农夫约翰知道他的奶牛很聪明,所以他希望确保它们不会在简单地试了很多不同的号码组合之后就能轻易开锁.锁上有三个转盘,每个上面有数字1..N (1 <= N <= 100),因为转盘是圆的,所以1和N是相邻的.有两种能开锁的号码组合,一种是农夫约翰设定的,还有一种“预设”号码组合是锁匠设定…
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. The combination lock is represented by n rotating disks w…
/* TASK:combo LANG:C++ URL:http://train.usaco.org/usacoprob2?a=E6RZnAhV9zn&S=combo SOLVE:自己做,想的是5*5*5*2-重复计算的. 官方题解是超级简单地写个判断枚举每一种解是否可行(n^3),题目没给n的范围,我就认为不可以用O(n^3)的算法. */ #include <iostream> #include <algorithm> #include <cstdio> #i…
长久不写算法题,这种简单题折腾了一下午... /* ID: yingzho2 LANG: C++ TASK: combo */ #include <iostream> #include <fstream> #include <string> #include <map> #include <vector> #include <set> #include <algorithm> #include <stdio.h>…
题目链接:http://codeforces.com/problemset/problem/540/A 题意: 输入的两个长度一样的数,求对应位置的某位数到下一个数需要最小的步长,每次只能先前或先后走以步,求所有的步长的的和.(如下例) Sample test(s) input 58219564723 output 13 解题: 这个很简单,暴力破解 可以把数字0-9是个长度是10的循环,对于任意两个数之间的最小距离就等于:min{|a-b|,|10-|a-b||} 对于两个数之间的距离很容易想…
题目 题目描述 农夫John的牛从农场逃脱出去了,所以他决定用一个密码锁来把农场的门锁起来,这个密码锁有三个表盘,每个表盘都是环形的,而且上面刻有1~N,现在John设了一个开锁密码,而且这个锁的设计者也有一个开锁密码.这个锁有一个特点,那就是它的容错方式,当我们输入密码时,如果我们的密码与正确的开锁密码相比较,对应的每一个表盘上的数字的距离都相差不超过2时,这个密码便可以打开这个锁. 例如:John设定的开锁密码为(1,2,3),锁的设计者的开锁密码为(4,5,6).如果我们现在将锁设定为(1…
题目链接:1.3.4 为了防止有重复的数字,我开了个三维数组来标记,爆内存,又用vector标记,爆内存... 不得不感慨这份代码. /* ID:wang9621 PROG:combo LANG:C++ */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; int…
Sample Input0 30 0 305 35 5 350 20 0 207 27 7 270 10 0 109 19 9 190 0 0 0Sample Output135013501620162018901890 =========================================================================================================== super simple等级 常量声明  R : 一圈有多少个…
题意:给出一个由26个小写字母组成的字符串,可以任意地进行若干个操作,每次操作是让指定区间内的字母变为下一个字母(z变成a).问是否存在方案使得这个字符串变为回文串. 一开始的想法是构造len/2条模26意义下方程,但由于26不是质数,判断有没有解并不容易.(下文自动省略模26) 我们发现,一次操作对于方程组的影响大概是这样的: 如上图所示,一次对区间[l,r]进行的操作,其中从一端到其关于中点的对称点的区间实质是没有贡献的.(上图中为区间[l,l'])同样地,对于完全位于中点右边的区间,可以将…
深搜,注意模n.用set去重. #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <iomanip> #include <cstring> #include <map> #include <queue> #include <set>…
/* TASK:combo LANG:C++ URL:http://train.usaco.org/usacoprob2?a=E6RZnAhV9zn&S=combo SOLVE:自己做,想的是5*5*5*2-重复计算的. 官方题解是超级简单地写个判断枚举每一种解是否可行(n^3),题目没给n的范围,我就认为不可以用O(n^3)的算法. */ #include <iostream> #include <algorithm> #include <cstdio> #i…
题意:给定一个串数,表示一种密码锁,再给定一串密码,问你滑动最少的次数,把第一行变成第二行. 析:很简单么,反正只有0-9这个10个数字,那么就是把每一个数从正着滑和倒着滑中找出一个最小的即可,正着滑就是大数减小数,倒着就是小数+10-大数. 代码如下: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e3 + 5; const int INF = 0x3f3f3f3f;…
combo解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------------------------------------------------------------------------------------------[题目] 一个三位密码锁,每位可能取值1~N.有两个解锁密码,都会给出. 若尝试的密码与某个解锁密码相等或相近(每位值都至多差2),均可解开…
一.题目大意 模拟一个开组合的密码锁过程.就像电影你开保险箱一样,左转几圈右转几圈的就搞定了.这个牌子的锁呢,也有它独特的转法.这个锁呢,有一个转盘,刻度为0~39.在正北方向上有一个刻度指针.它的密码组合有三个数,开锁的套路为:先把刻度盘顺时针转两圈,然后再顺时针转到第一个数,再把刻度盘逆时针转一圈,再逆时针转到第二个数,最后再顺时针转到第三个数.这里的转到那个数是指将刻度盘上的数转到指针处.起始位置和组合密码有标准输入给出.求圆盘转过的总度数(顺时针加上逆时针).注意刻度盘上还有一个凸起的圆…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟水题 [代码] #include <bits/stdc++.h> using namespace std; const int N = 1000; //no pain no gain int a[N+10],b[N+10],n; int get_ans(int x,int y){ int temp = x; int ans = 0; while (temp!=y){ ans++; temp--; if (temp<0…
A. Gennady and a Card Game a题惯例签到题 题意:给你一张牌,再给你5张牌,判断能不能出一次牌... 所以只要检查第二行中的某个卡是否与第一行中的卡具有共同字符 有就输出YES否则输出NO #include<iostream> #include<cstring> #include<cstdio> using namespace std; char a,b,s[101]; bool tf=0; int main(){ scanf("%c…
又回来了.. A - Gennady and a Card Game 好像没什么可说的了. #include<bits/stdc++.h> using namespace std; char gc() { static char buf[100000],*p1,*p2; return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin))?EOF:*p1++; return getchar(); } template<class…
A. Gennady and a Card Game 签到. #include <bits/stdc++.h> using namespace std; ], t[]; bool solve() { int flag = false; ; i <= ; ++i) { scanf("%s", t); ] == s[] || t[] == s[]) flag = true; } return flag; } int main() { while (scanf("…