簡單的計數,只要做到不重,不漏,就應該能過了。 下面是代碼,因為是厚白數上的例題,所以自己很沒譜。 #include<iostream>using namespace std;long long ans[10000010];int main(){ ans[3]=0; for(long long i=4;i<=10000010;i++) ans[i]=ans[i-1]+((i-1)*(i-2)/2-(i-1)/2)/2; int n;
Popular CowsTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 19089 Accepted: 7678DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <=
Problem C: Arctic NetworkThe Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio
It's not a Bug, it's a Feature! It is a curious fact that consumers buying a new software product generally do not expect the software to be bug-free. Can you imagine buying a car whose steering wheel only turns to the right? Or a CD-player that
Problem DThe Tourist GuideInput: standard inputOutput: standard output Mr. G. works as a tourist guide. His current assignment is to take some tourists from one city to another. Some two-way roads connect the cities. For each pair of neighboring
題目給的是個三維的圖形,那麼就開一個三維的數組,然後用bfs就ok啦!下面是代碼:#include<iostream>#include<stdio.h>#include<cstring>using namespace std;#define MAXN 31struct node{ int l; int r; int c; int t; node(){} node(int x,int y,int z,int
/*連續兩道題目的資料有問題,Ora。剛開死將這道題想簡單了,直接類比做的,額...*/#include<cstdio>#include<cstring>#include<string>#include<iostream>#include<cstdlib>using namespace std;const int maxn = 1001;const int Min = -100000000;int
因為沒有權值,所以不用使用Floyd演算法求最短路。直接用bfs做。。。#include<cstdio>#include<cstring>using namespace std;const int maxn = 21;int G[maxn][maxn];int vis[maxn][maxn];struct node{ int level; int u;} q[maxn*maxn];int bfs(int s,int e){ int front = 1;
Problem B: Audiophobia Consider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. But we apprehend that many of your descendants may not have this luxury. For, as you know, we are the
Problem EConnect the CampusInput: standard inputOutput: standard outputTime Limit: 2 secondsMany new buildings are under construction on the campus of the University of Waterloo. The university has hired bricklayers, electricians, plumbers, and a