sgu_51CTO博客
手写链表#include#includeusing namespace std;char s;int tem,head,nex,last;struct word{ char c; int next; int last;}seq[1000100];int main(){ int i,f=1; /
原创 2023-09-15 09:37:37
55阅读
405. TotalizatorTime limit per test: 0.25 second(s)Memory limit: 65536 kilobytesinput: standardoutput: standardSome time ago Vasya was cleaning up the...
qt
原创 2021-07-16 15:02:47
153阅读
题意:从n个数中,选择一些数,使得异或最大。 1 #include 2 #include 3 #include 4 #define ll __int64 5 using namespace std; 6 7 ll c[110][110]; 8 int n; 9 ll cc;10 11 voi...
转载 2014-08-20 18:39:00
160阅读
2评论
SGU_115     类似这种日期的问题貌似还是写几个小函数处理起来更明了一些。 #include<stdio.h>#include<string.h>int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int M = 10, D = 21, W = 7;int equals(int m, i
转载 2012-03-06 18:54:00
72阅读
2评论
SGU_123     斐波那契数列前n项和为2*F(n+1)-F(n-1)-1。 #include<stdio.h>#include<string.h>long long int f[50];int main(){int i, j, k; f[0] = 0, f[1] = 1;for(i = 2; i <= 41; i ++) f[i] = f
转载 2012-01-13 22:46:00
41阅读
2评论
SGU_106     这个题目AC了的程序也写的不尽相同,但就NOWCOW上面的那个C++程序来说,处理某些数据确实存在问题,所以最好还是写自己的思路了。     我的思路就是首先把一个基本解求出来,然后看在x1、x2的范围内x的范围是多少,然后找到对应的y的范围,再看y的范围有多少个解是在y1、y2范围之内的,这个就是最后的答案。     当然,对于含有a=0或b=0的情况要特判一下。 #i
转载 2011-12-24 17:19:00
249阅读
2评论
SGU_102     一开始直接用gcd暴力也能过,后来看了别人的解题报告发现可以用欧拉函数,以前用过一次但现在忘记了,于是又学了一遍。 #include<stdio.h>#include<string.h>#include<math.h>int N;void solve(){int i, j, k = (int)sqrt(N + 1), res = N;f
转载 2011-12-09 19:09:00
37阅读
2评论
406. GoggleTime limit per test: 0.25 second(s)Memory limit: 65536 kilobytesinput: standardoutput: standardEverybody knows search engine Goggle. But on...
qt
原创 2021-07-16 15:02:48
94阅读
249. Matrixtime limit per test: 1 sec.memory limit per test: 65536 KBinput: standardoutput: standardIt is necessary to arrange numbers from 0 to 2^(N+M)-1 in the matrix with 2^N rows and 2^M columns. Moreover, numbers occupying two adjacent cells must differ only in single bit in binary notation. Ce
IT
原创 2021-07-29 16:29:08
105阅读
SGU_206     不得不说这个题目的思想太奇葩,一时间还是不能很理解……     首先一个贪心的思路就是,石子路的d[i]一定是小于或等于c[i]的,而非石子路的d[j]是一定大于或等于c[j]的,如果我们用x[i]描述石子路谎报的增量那么有x[i]=c[i]-d[i],用y[j]描述非石子路谎报的增量那么有y[j]=d[j]-c[j],最后目标自然就是求sum{x[i]}+sum{y[j]
转载 2012-08-19 15:56:00
89阅读
2评论
原题链接 考察:扩展gcd 思路: 套exgcd模板但是答案没有那么简单!!! 坑点: 存在!a||!b的情况,此时答案是系数为0的变量的范围.但是if !a&&!b 此时只有!c才存在答案. 此时a&&b, 我们可以求出x,y的某一个解.如果直接while(x+=b/d)统计会TLE.因此必须转换
转载 2021-03-23 01:02:00
114阅读
2评论
题意:给出一个只可能包含0,1,2的字符串,给定需要的0的个数a和需要的1的个数b,使用最少的替换次数得到目标串,输出交换次数。做法:简单模拟即可代码:#include #include #include #include using namespace std;int main() { int n,a,b; string s; while(cin>>n>>a>>b>>s) { if(a+b>n) {puts("-1");continue;} int c = n-a-b, i; int x=count(s.begin()
转载 2013-02-05 15:56:00
42阅读
2评论
题意:海盗有n个人,他们预计得到Y个金币,然后第i个人分到xi个金币,然而最后他们得到m个金币,要怎么分使得他们的到的金币与预期的差值(绝对值)的和最小 解题代码:每个人先分到金币预期的向下取整,得到的和肯定小于n,,,然后再根据每个+1以后对和的影响排序,然后把多余的金币z分给前z个人 解题代码:(这里贴上watashi的解题代码) 1 #include <stdio.h>
转载 2013-09-05 19:33:00
52阅读
2评论
题意:给出一个n×n的矩阵,矩阵上每个格子最开始都是白色的,给出m个操作,每个操作会把一个矩形染成黑色或白色,问最后有多少个白的格子。 思路:这题让我不禁想起了poj 2528,这类的染色问题应该都能用并查集搞……从后往前处理操作,这样已经画过的地方就不会第二次被染色,然后把染过的标记一下,接下来就
转载 2021-03-31 11:31:00
85阅读
2评论
SGU_117     直接应用快速幂取模即可。 #include<stdio.h>#include<string.h>int N, M, K;int pow_mod(int a, int n){int ans;if(n == 1)return a % K; ans = pow_mod(a, n / 2); ans = ans * ans % K;if(n %
转载 2012-01-13 21:27:00
62阅读
2评论
SGU_101     这个可以把骨牌看成一条边,把数字看成点,这样最后实际上就是去求一条欧拉道路。     对于无向图欧拉道路要求:①图必须连通;②度数为奇数的点没有或者只有两个。     不符合上述要求自然就无解了,如果有解选一个度数为奇数的点(如果没有就任取一个点)用dfs遍历一遍图把欧拉道路打印出来即可。 #include<stdio.h>#include<string
转载 2011-12-09 17:58:00
71阅读
2评论
题意:构造哈夫曼数,求出其中产生节点值的和 解题思路:裸优先队列(最小堆),渣渣只会堆 解题代码: 1 // File Name: c.cpp 2 // Author: darkdream 3 // Created Time: 2013年09月04日 星期三 14时50分35秒 4 5 #include<vector> 6 #include<list
转载 2013-09-05 19:37:00
43阅读
2评论
首先统计下两个字串长度,+个数是否相同,不同肯定无解。因为每个+对应一个匹配
原创 2023-07-17 18:10:58
40阅读
180. Inversionstime limit per test: 0.25 sec.memory limit per test: 4096 KBinput: standardoutput: standardThere are N integers (1A[j].InputThe first line of the input contains
原创 2023-04-24 09:04:28
43阅读
403. Scientific ProblemTime limit per test: 0.25 second(s)Memory limit: 65536 kilobytesinput: standardoutput: standardOnce upon a time Professor Idiot...
qt
原创 2021-07-16 15:03:27
178阅读
  • 1
  • 2
  • 3
  • 4
  • 5