
sgu oj
Cheky_
这个作者很懒,什么都没留下…
展开
-
sgu 222
#include int p(int a, int b) { if (b > a) { return 0; } else if (b == 0) { return 1; } else { int i = a - b + 1; int r = a; while (i < a) { r *= i; ++i; } return r; }}in原创 2013-03-06 17:58:39 · 593 阅读 · 0 评论 -
sgu 318
/*** * 以资源为列,用户为行,统计资源列有多少个不同值,去掉空值,即为答案。 */import java.util.*;import java.io.*;public class Solution {public static void main(String[] argv) throws IOException {BufferedReader in = new BufferedReader原创 2015-10-11 11:36:38 · 418 阅读 · 0 评论 -
sgu 178
f(n)表示问题的解 第一步:将n0 = n分成三部分a1 ,b1= 1, n1;其中a1 = n0 - n1 - 1,a1 〉= n1;n1 是之后要分解的 ,可行解为 f(n1)我们得到 a1,b1, f(n1)前n1天,用n1(会拆开)支付,解为f(n1)第n1+1天用 b1支付第n1+2天用a1(完整的)支付,必须找零a1 - 1,店主有n1+1个,所以必须有原创 2013-07-23 17:17:30 · 780 阅读 · 0 评论 -
sgu 125
AC之后看大网上别人的基本是dfs、暴力搜索因为我的算法不是这样,贴出来看看sgu结果: Accepted 31 ms 835 kb 英文很烂,注释看不懂可email /** * @file * @brief my c solution for problem 125 on SGU OJ * @author ck * @date 2013-06-19 *原创 2013-06-20 21:49:42 · 889 阅读 · 0 评论 -
sgu 120
#include #include const double PI = 3.1415926535897932384626;int n, n1, n2;double n1x, n1y, n2x, n2y;int main() { scanf("%d%d%d", &n, &n1, &n2); scanf("%lf%lf%lf%lf", &n1x, &n1y, &n2x, &n2原创 2013-04-16 20:30:23 · 509 阅读 · 0 评论 -
sgu 193
/* if n = a*b + r and gcd(n, r) = 1 then ans = max{a, b} (a, b <= n/2) if n = 2p + 1 then ans = p; else n = 2p let p = 2q+r if r=0 then n = 4q =2(2q - 1) + 2, gcd(n, 2q-1) = gcd(原创 2013-04-15 15:16:19 · 535 阅读 · 0 评论 -
sgu 226
/*notice: the graph may contain loops between two point,there may be many ways that have different color */#include #include using namespace std;const int INF = 0x7ffffffe;int n, m;int原创 2013-04-10 11:16:52 · 651 阅读 · 0 评论 -
sgu 403
/* 是某某的1/x 居然被翻译成: which is x times less than ... */#include int main() { int x; scanf("%d", &x); printf("%d\n", (x<<1) + 1); return 0;}原创 2013-04-07 17:01:26 · 506 阅读 · 0 评论 -
sgu 224
//dfs// k = 0, ans = 1;// k = 1, ans = n*n ;// k > n, ans = 0;//还可以进一步优化 // if (n - ps < k - count) rollback; 当剩余列数小于剩余棋子数时,回滚// 对称性优化, 第一个棋子放在某一列m行,和放在该列n-m+1// 直接用数组保存所有结果 ---原创 2013-04-07 14:46:37 · 695 阅读 · 0 评论 -
sgu 259
/* greedy method sort the leaflets by Li by descending order let sumTk = Ti + T2 + ..... Tk answer = max ( sumTk + Lk), k = 1...nproofproof by contradiction : 假设最优序列为 a = { 1, 2, 3 ..原创 2013-04-05 17:38:12 · 597 阅读 · 0 评论 -
sgu 223
/*状态压缩dp每一行的可行状态进行压缩 , n=3时 s = {000, 001, 010, 100, 101}d[row][si][p] 表示 第row行状态为si,前row-1行已放置且不冲突,总共放了p个棋子的方案数初始状态 d[0][0][0] = 1, others = 0;递推公式 d[row][s[i]][p + c[i]] = sigma(d[row-1][s[j]原创 2013-04-03 10:10:28 · 623 阅读 · 0 评论 -
sgu 296
#include #define NONE 'n'/*升序数列,删除前面的高位降序数列,删除后面的低位先处理升序*/char n[1009];int k;// find the next digit after digit a, return -1 when can not find.int next(int a) {原创 2013-03-11 15:57:18 · 519 阅读 · 0 评论 -
sgu 316
题目中: Each shot always reduces the hit points of the target tank by 8, and if the number of hit points of the targetbefore the shot was greater than zero, the shooting tank receives 3 score points.原创 2013-03-09 17:02:40 · 830 阅读 · 0 评论 -
sgu404
#include int main() { int n, m, i ; char s[109]; scanf("%d%d", &n, &m); n %= m; if (n==0) { n = m; } for (i=1; i<=m; ++i) { scanf("%s", s); if (i原创 2013-03-09 15:49:14 · 479 阅读 · 0 评论 -
sgu 302
#include #include void putUpper(char c) { if (c >= 'a') { //c is lowercase putchar(c - 32); } else { putchar(c); }}void putLower(char c) { if (c <= 'Z') {原创 2013-03-08 16:42:25 · 613 阅读 · 0 评论 -
sgu 276
#include int main() { int p, s; int t[] = {1, 300, 900, 1800, 10800 }; scanf("%d%d", &s, &p); p -= s; s = 0; while (t[s] <= p) ++s; printf("%d\n", s); return 0原创 2013-03-08 14:41:18 · 562 阅读 · 0 评论 -
sgu oj 说明
做sgu oj的一些ac代码sgu地址 : http://acm.sgu.ru/我的帐号 052435原创 2013-03-06 18:03:43 · 1271 阅读 · 0 评论 -
sgu499
//暴力求解复杂度为O(n(n-1)/2)//假设所有输入中最大值为maxp,枚举i=maxp to 1(从大到小枚举),//如果i是某两个数的约数,则i是所有数的最大最大公约数。//复杂度 ??#include #include #define maxn 1000005 int num[maxn]; int main() { int n,i,j,k;原创 2016-02-23 21:07:00 · 543 阅读 · 0 评论