A. Help Farmer 题目连接: http://www.codeforces.com/contest/142/problem/A Description Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocki…
枚举直线,对于直线的某个点在直线的左端还是右端,能够状压出一个数.用bitset记录. 然后三角形就是3个bitset&一下 #include <cstdio> #include <cstring> #include <bitset> #include <algorithm> using namespace std; typedef long long ll; const int N = 101; const int M = 1005; bitset…
暴力枚举. 枚举最小的那个数字,不会超过$1000$,剩下的两个数字根号的效率枚举一下即可. #include<bits/stdc++.h> using namespace std; long long n; long long ansMin,ansMax; int main() { scanf("%lld",&n); ansMin=1e18; ansMax=-; ); p++; ;x1<=p;x1++) { if(n%x1) continue; long l…
My guitar playing and singing 码农的自娱自乐 https://v.youku.com/v_show/id_XNDM4NTY1MTEwNA==.html?spm=a2hzp.8244740.0.0 https://v.youku.com/v_show/id_XNDMyOTMxNTY5Ng==.html?spm=a2h0j.11185381.listitem_page1.5~A https://v.youku.com/v_show/id_XNDQxNTI3NDgwOA=…
题目大意:有N头奶牛,每头那牛都有一个标号Pi,1 <= Pi <= M <= N <= 40000.现在Farmer John要把这些奶牛分成若干段,定义每段的不河蟹度为:若这段里有k个不同的数,那不河蟹度为k*k.那总的不河蟹度就是所有段的不河蟹度的总和. 思路:显然如果连续的一段数字相同,我们可以把它们合并成一个数字. 用f[i]表示在1~i这一段的最小不河蟹度.因为答案最大为n,显然不可能出现一段中有超过sqrt(n)个不同的数. 定义b[j],使b[j]+1~i中不同的数…
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…