标签:
这场CF,准备充足,回寝室洗了澡,睡了一觉,可结果。。。
第一次忘记判断相等时A先走算A赢,hack掉。后来才知道自己的代码写错了(摔
for (int i=1; i<=8; ++i) {
scanf ("%s", s[i]); //!!!
}
数学(找规律) B - The Monster and the Squirrel
题意:多边形每个顶点向其它的点引射线,如果碰到其他射线则停止,问最后多边形被分成多少个区域

分析:搬题解:
After drawing the rays from the first vertex (n - 2) triangles are formed. The subsequent rays will generate independently sub-regions in these triangles. Let‘s analyse the triangle determined by vertices 1, i, i + 1, after drawing the rays from vertex i and (i + 1) the triangle will be divided into (n - i) + (i - 2) = n - 2 regions. Therefore the total number of convex regions is (n - 2)2

If the squirrel starts from the region that have 1 as a vertex, then she can go through each region of triangle (1, i, i + 1) once. That implies that the squirrel can collect all the walnuts in (n - 2)2 jumps.
我一直在猜结论,试了一些公式,但和3,4的情况对不上。(卒
注意爆int
题意:两个在比赛,每个人的速度固定,终点<=t,问两人不分胜负的可能情况
分析:分类讨论,如果LCM (b, w) <= t, 那么每个LCM的倍数的点以及之后跟着的min (b, w) - 1都是不分胜负的,其他情况不详细分析。。。
注意的是LCM可能爆long long,可以先除和t比较或者转换成double log函数比较
/************************************************
* Author :Running_Time
* Created Time :2015/10/31 星期六 22:41:05
* File Name :C.cpp
************************************************/
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos (-1.0);
ll GCD(ll a, ll b) {
return b ? GCD (b, a % b) : a;
}
int main(void) {
ll t, w, b; scanf ("%I64d%I64d%I64d", &t, &w, &b);
if (w > b) swap (w, b);
if (w > t && b > t) {
printf ("1/1\n");
}
else if (b > t) {
ll x = GCD (w - 1, t);
printf ("%I64d/%I64d\n", (w - 1) / x, t / x);
}
else if (log ((double) w) + log ((double) b) - log ((double) GCD (w, b)) > log ((double) t)) {
ll x = GCD (w - 1, t);
printf ("%I64d/%I64d\n", (w - 1) / x, t / x);
}
else {
ll lcm = b / GCD (w, b) * w;
if (t % lcm == 0) {
ll y = (w - 1) + (t / lcm - 1) * w + 1;
ll x = GCD (y, t);
printf ("%I64d/%I64d\n", y / x, t / x);
}
else {
ll y = (w - 1) + (t / lcm - 1) * w + (1 + min (t % lcm, w - 1));
ll x = GCD (y, t);
printf ("%I64d/%I64d\n", y / x, t / x);
}
}
//cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
return 0;
}
Codeforces Round #328 (Div. 2)
标签:
原文地址:http://www.cnblogs.com/Running-Time/p/4931517.html