102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB 题解: 求一个1-10000之间的数 N 的互质数个数.题目很简单,有两种方法: 1.复杂度是O(n^2),依次判断从1到N-1的数是否与N互质. ​2.复杂度是O(n),换一种想法,先求与N不互质的数的个数,然后用N减去即可.例如9,从2开始循环,3与9不互质,那么3的倍数也与9不互质,所以6也与9不互质.因为N很小,所以可以开一个数组a[10…
101. Domino time limit per test: 0.25 sec. memory limit per test: 4096 KB 题解: 求多米诺骨牌按照一定方式放置能否使相邻的位置数字相同.其实就是求无向图的欧拉通路,dfs即可. 但需要注意以下几点: 1.注意是否是连通图. 2.注意自环. 3.注意有两个奇度顶点时深搜起点. 以下是代码: #include <iostream> #include <cstdio> #include <cstring>…
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB 问题: 你想要将你的花窗安排得最具美感.有F束花,每一束花都不一样,至少有F个按顺序排成一行的花瓶.花瓶从左到右,依次编号1-V.而花放置的位置是可以改变的,花依次编号1到F.花的序号有一个特征,即是序号决定了花束出现在花瓶里的顺序.例如,有两束花编号i和j,满足i<j,那么i所在的花瓶一定要在j所在花瓶的左边,即是i…
103. Traffic Lights Time limit per test: 0.25 second(s) Memory limit: 4096 kilobytes 题解: 1.其实就是求两点间的最短路,不过加了交通灯的限制,使得两点间的所需时间并不只是由路程决定. 2.只有一条路两个端点的交通灯颜色相同时,该路才可以通过.但是这有一种情况,当两个交通灯处于不同颜色时,经过t时间,交通灯又恰好处于不同颜色,由于最初有一个颜色预变时间riC以及蓝色tiB.紫色周期tiP ,那么就需要计算交通灯…
100.A+B time limit per test: 0.25 sec. memory limit per test: 65536 KB 题解:上手题,不解释. 直接上代码: #include <iostream> using namespace std; int main(){ int a, b; cin >> a >> b; cout << a + b << endl; return 0; }…
Array Diversity Time Limit:404MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Description Here we go! Let's define the diversity of a list of numbers to be the difference between the largest and smallest number in the list. For example, the…
太水了, 我都不忍心发题解, 但毕竟是sgu上一道题, 我试试能不能一直这么写下去,就是求phi,上代码 #include <cstdio> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <cmath> #define N 10010 using namespace std; int get_phi(int…
Time Limit:3000MS     Memory Limit:0KB Description Queues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known, though it occurs often in everyday life. At lunch time the q…
Time Limit:3000MS     Memory Limit:0KB Description Background Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world i…
Time Limit:2000MS     Memory Limit:65536KB Description Given a string consisting of brackets of two types find its longest substring that is a regular brackets sequence. Input There are mutiple cases in the input file. Each case contains a string con…