BestCoder Round #46

1001 YJC tricks time

题目链接:1001

题意:给你时针和分针所成的角度,输出现在的时间,以10秒为单位

思路:每10秒,分针走1度,时针走分针的1/12,我们可以根据时间来分别计算出分针和时针走的度数(分针可能走多圈),然后计算出二者的夹角(按题目的格式*12000)

我们可以得到一张时间对夹角的map表,对于输入的夹角,去map中查找是否存在对应的时间即可,除了0和06:00:00以外其他的夹角都对应两个时间,这两个时间互补。

code:

 1 #include <cstdio>
 2 #include <map>
 3 using namespace std;
 4 const int MAXN = 43200;
 5 const int MOD = 4320000;
 6 map<int, int> mp;
 7
 8 void init()
 9 {
10     for (int i = 0; i < MAXN; i += 10)
11     {
12         int t1 = i * 1200 % MOD;
13         int t2 = i * 100;
14         int t = t1 - t2;
15         if (t2 > t1) t = t2 - t1;
16         if (t > 2160000) t = MOD - t;
17         mp[t] = i;
18     }
19 }
20
21 void solve(int n)
22 {
23     int hh = n / 3600;
24     int mm = (n - hh * 3600) / 60;
25     int ss = n - hh * 3600 - mm * 60;
26     printf("%02d:%02d:%02d\n", hh, mm, ss);
27 }
28
29 int main()
30 {
31     init();
32     int n;
33     while (scanf("%d", &n) != EOF)
34     {
35         if (mp.count(n))
36         {
37             int t = mp[n];
38             if (t != MAXN - t && t != 0) solve(MAXN - t);
39             solve(t);
40         }
41     }
42     return 0;
43 }
时间: 2024-07-31 14:28:11

BestCoder Round #46的相关文章

暴力 BestCoder Round #46 1001 YJC tricks time

题目传送门 1 /* 2 暴力:模拟枚举每一个时间的度数 3 详细解释:http://blog.csdn.net/enjoying_science/article/details/46759085 4 期末考结束第一题,看看题解找找感觉:) 5 */ 6 #include <cstdio> 7 #include <algorithm> 8 #include <cstring> 9 #include <vector> 10 #include <iostr

BestCoder Round #4 前两题 hdu 4931 4932

第一题太水了.. 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 int a[6]; 7 int main(){ 8 int cas; 9 scanf( "%d", &cas ); 10 while( cas-- ){ 11 for( int i = 0; i <

BestCoder Round #88

传送门:BestCoder Round #88 分析: A题统计字符串中连续字串全为q的个数,预处理以下或加个cnt就好了: 代码: 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <ctime> 5 #include <cmath> 6 #include <iostream> 7 #include <algorithm> 8

从lca到树链剖分 bestcoder round#45 1003

bestcoder round#45 1003 题,给定两个点,要我们求这两个点的树上路径所经过的点的权值是否出现过奇数次.如果是一般人,那么就是用lca求树上路径,然后判断是否出现过奇数次(用异或),高手就不这么做了,直接树链剖分.为什么不能用lca,因为如果有树退化成链,那么每次询问的复杂度是O(n), 那么q次询问的时间复杂度是O(qn) 什么是树链剖分呢? 就是把树的边分成轻链和重链 http://blogsina.com.cn/s/blog_6974c8b20100zc61.htmlh

BestCoder Round #32

PM2.5 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 613    Accepted Submission(s): 326 Problem Description Nowadays we use content of PM2.5 to discribe the quality of air. The lower content of

hdu 5195 DZY Loves Topological Sorting BestCoder Round #35 1002 [ 拓扑排序 + 优先队列 || 线段树 ]

传送门 DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 221    Accepted Submission(s): 52 Problem Description A topological sort or topological ordering of a directed

Bestcoder BestCoder Round #28 A Missing number(查找缺失的合法数字)

Problem Description There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose. Input There is a number T shows there are T test cases below. (T<=10T≤10)For each test case

DP BestCoder Round #50 (div.2) 1003 The mook jong

题目传送门 1 /* 2 DP:这题赤裸裸的dp,dp[i][1/0]表示第i块板放木桩和不放木桩的方案数.状态转移方程: 3 dp[i][1] = dp[i-3][1] + dp[i-3][0] + 1; dp[i][0] = dp[i-1][1] + dp[i-1][0]; 4 比赛时二维dp写搓了,主要是边界情况的判断出错,比如dp[3][1] = 1,因为第3块放了木桩,其他地方不能再放,dp[3][0]同理 5 解释一下dp[i][1]的三种情况,可能是前面相隔2个放的方案或者是不放的

计算几何(水)BestCoder Round #50 (div.2) 1002 Run

题目传送门 1 /* 2 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 3 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 4 */ 5 /************************************************ 6 * Author :Running_Time 7 * Created Time :2015-8-8 19:54:14 8 * File Name :B.cpp 9 ************