Continuous Login Time Limit: 2 Seconds Memory Limit: 131072 KB Special Judge Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a continuous login reward. The mechanism of continuous log…
problem description http://acm.hdu.edu.cn/showproblem.php?pid=1030 #include <cstdio> #include <cmath> #include <algorithm> int calPathLength(int x, int y) { //path length from 1 (1st line, lower) to a number in ith line is only differ by…
哈密顿绕行世界问题 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 66 Accepted Submission(s) : 33 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 一个规则的实心十二面体,它的 20个顶点标出世界著名的…
Ranking System Time Limit: 2 Seconds Memory Limit: 65536 KB Few weeks ago, a famous software company has upgraded its instant messaging software. A ranking system was released for user groups. Each member of a group has a level placed near his n…
Speed Limit Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 17967 Accepted: 12596 Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately…
as Scott Meyers said in his book Effective STL, "My advice on choosing among the sorting algorithms is to make your selection based on what you need to accomplish, not on performance considerations. If you choose an algorithm that does only what you…
B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeiste…
the 2 version are essentially the same, except version 2 search from the larger end, which reduce the search time in extreme condition from linear to constant, so be faster. version 1 #include <cstdio> #include <algorithm> struct LWPair{ int l…
Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11893 Accepted: 3408 Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share the…
bit masking is very common on the lower level code. #include <cstdio> #include <algorithm> #define MAXSIZE 205 char line[MAXSIZE]; int main() { //freopen("input.txt","r",stdin); int x,y, dir; // (dir&3) 0,1,2,3 -- right…
partial sort. first use std::nth_element to find pivot, then use std::stable_partition with the pivot to partition the largest k, whose indices are in acsending order, print them in reverse order. p.s. lambda expression is also used. STL is powerful.…
#include <cstdio> #include <iostream> #include <cstring> #include<queue> using namespace std; const int INF = 0x3fffffff; int g[1005][1005]; bool vis[1005]; int m; int Edmond_Karp(int s,int t) { int pre[1005]; int flow[1005]; memse…
覆盖的面积 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3553 Accepted Submission(s): 1743 Problem Description 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. Input 输入数据的第一行是一个正整数T(1<=T<=100),代表测试数据的数量.每个测…
这题目看一眼以为难度评级出错了,只是一个求余数的题目,,后来才发现,位数小于百万位,,,我还以为是大小小于百万呢,所以借鉴了另一大神的代码, 用大数,重点是同余定理: (a+b)mod m=((a mod m)+(b mod m))mod m; a*b mod m=(a mod m)*(b mod m) mod m; a^b mod m=(a mod m)^b mod m; #include<stdio.h> #include<string.h> #include<stdli…
#include<stdio.h> int main(){ long long a,b,c,d,e,f; while(scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f)!=EOF){ if(a*c*e*b*d*f==0){ if(d==0)printf("Hermione"); else{ if(c==0)printf("Ron");…