随笔分类 - Codeforces
Codeforces
摘要:题解移步至:http://blog.csdn.net/huzecong/article/details/12174359(斜眼笑)A: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int n; 8 9 int main()10 {11 scanf("%d",&n);12 int max=0;13 long long sum=0;14 for (int a=1;amax) max=v;19 sum+=v;20 }21 sum=(sum-1)/(n-...
阅读全文
摘要:A:…… 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 int main() 9 {10 int x,y;11 scanf("%d%d",&x,&y);12 int x1,y1,x2,y2;13 x1=0;y1=(abs(y)+abs(x))*(y>0 ? 1 : -1);14 x2=(abs(x)+abs(y))*(x>0 ? 1 : -1);y2=0;15 if (x1>x2) swap(x1,x2),swap(y1,y2);16 ...
阅读全文
摘要:A:扫一遍。 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int n; 8 9 char s1[3],s2[3];10 11 int main()12 {13 scanf("%d",&n);14 int ans=1;15 scanf("%s",s1);16 for (int a=2;a 2 #include 3 #include 4 5 using namespace std; 6 7 int main() 8 { 9 int a,b,c;10 scanf(...
阅读全文
摘要:A:不会做……B:看不懂题……C:二分答案顺序检验。 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 const int maxn=100010; 9 10 int n,m;11 12 long long z[maxn],y[maxn];13 14 bool check(long long v)15 {16 int p=1;17 for (int a=1;a>1));24 while (pm;36 }37 38 int main()39 {40 ...
阅读全文
摘要:A:只可能有1 2 4、1 2 6、1 3 6三种情况,先把4分光然后就乱搞了。 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int n,cnt[10]; 8 9 int main()10 {11 scanf("%d",&n);12 for (int a=1;acnt[2])24 {25 printf("-1\n");26 return 0;27 }28 while (cnt[6])29 {30 if (cnt[3...
阅读全文
摘要:A:题意不知道,似乎是排序。 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 const int maxn=60; 9 10 int n,m,z[maxn];11 12 int main()13 {14 scanf("%d%d",&n,&m);15 for (int a=1;a 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 int a,b,c,d; 9 10 int gcd(int a
阅读全文
摘要:D:定义表G(i,j)=gcd(i,j),给出一段序列,问该序列是否在n*m的G表上的某一行出现过。首先考虑行,设x为该序列所有数的最小公倍数,那么首先x肯定是可以满足该表的需求的,而更大的x的倍数只可能导致数列中的值变大,所以我们只需要检验行为x是否存在答案即可。然后考虑列,设序列中的数位z1、z2……,如果我们最后求出来的列为j,那么我们有:gcd(x,j)=z1gcd(x,j+1)=z2……由这些式子可以得出:j mod z1=0j+1 mod z2=0……于是变成多个同余方程的问题,中国剩余定理解出最小的j,如果此时不满足那么更大的j也肯定不满足。因为下一个满足的j为j+x,但是j+x
阅读全文
摘要:这是一场5道题都写不到1K的CF。A:题意是排序。 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 int n,z[100]; 9 10 char s[100];11 12 int main()13 {14 scanf("%s",s+1);15 int l=strlen(s+1);16 s[l+1]='+';17 int p=1;18 while (s[p]>='0' && s[p] 2 #include 3 #includ
阅读全文
摘要:A:询问[l,r]之间有多少个能被x整除的数。这是简要的题意,分类居然是math。 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int gcd(int a,int b) 8 { 9 if (!b) return a;10 else return gcd(b,a%b);11 }12 13 int main()14 {15 int x,y,a,b;16 scanf("%d%d%d%d",&x,&y,&a,&b);17 x=x/gcd(x,y)*y;18 printf(
阅读全文
摘要:D:二维矩阵区间xor上一个数询问区间xor和。嘛,如果不是xor应该是没法做的吧。因为是xor,所以我们只需要考虑修改的区间的数有多少个,是奇数个还是偶数个之类的就行了,因为xor两次等于不xor嘛,所以对行列的奇偶用树状数组维护就行了。 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 #define lb(x) ((x)&(-(x))) 8 9 const int maxn=1010;10 11 int n,m,z[2][2][maxn][maxn];12 13 void modify(int x,int
阅读全文
摘要:336:http://www.cnblogs.com/zhonghaoxi/p/3330527.html337:http://www.cnblogs.com/zhonghaoxi/p/3294237.html338:http://www.cnblogs.com/zhonghaoxi/p/3294230.html339:http://www.cnblogs.com/zhonghaoxi/p/3294223.html340:http://www.cnblogs.com/zhonghaoxi/p/3293601.html341:http://www.cnblogs.com/zhonghaoxi/p/
阅读全文


浙公网安备 33010602011771号