随笔分类 -  SGU

SGU132 - Another Chocolate Maniac(状态压缩DP)
摘要:题目大意 给定一个N*M大小的大小的蛋糕,蛋糕的有些地方已经放置了东西,要求你在蛋糕上放入尽量少的1*2大小的巧克力,使得蛋糕不能够再放入巧克力 题解 和POJ1038恰好相反,此题是放入尽量少的巧克力,根据前两行的状态来进行当前行的放置,用dfs来进行三行的状态枚举,并同时检查放置是否合法,放完m列之后就可以进行状态转移了 代码: #include #include #include #incl... 阅读全文

posted @ 2013-12-11 19:19 仗剑奔走天涯 阅读(501) 评论(0) 推荐(0)

SGU223 - Little Kings(状态压缩DP)
摘要:题目大意 给定一个N*N(n#include #include #include using namespace std;#define MAXN 11typedef long long LL;LL dp[MAXN][1>=1; } return ret;}void pre_solve(int n){ for(int i=0;i>1))) { ... 阅读全文

posted @ 2013-12-03 13:22 仗剑奔走天涯 阅读(485) 评论(0) 推荐(0)

SGU131 - Hardwood floor(状态压缩DP)
摘要:题目大意 给定一个N*M大小的矩形,要求你用1*2和2*2(缺个角)的砖块把矩形铺满(不能重叠),问总共有多少种铺法? 题解受POJ2411的影响,怎么都没想到3,4,5,6这几种情况该怎么放置,看了网上大牛的解题报告和代码(真是不好的习惯,可是太弱了就是想不出咋办%>_#include#include#includeusing namespace std;#define MAXN 10typed... 阅读全文

posted @ 2013-12-03 10:06 仗剑奔走天涯 阅读(519) 评论(0) 推荐(0)

SGU180 - Inversions
摘要:题目大意给定N个数,a1,a2,3,a4..an,要求你求出这样的对数:i<=i<j<=n并且a[i]>a[j]。题解就是逆序对问题。。。果断用树状数组做,数据有点大0<=Ai<=10^9,需要进行离散化,离散的时候注意会有相同的数,最先没注意这个,提交上去第二组数据就WA了。代码#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#define MAXN 70000using namespace std;typedef s 阅读全文

posted @ 2013-04-17 15:23 仗剑奔走天涯 阅读(423) 评论(0) 推荐(0)

SGU107 - 987654321 problem
摘要:107. 987654321 problemtime limit per test: 0.5 sec.memory limit per test: 4096 KBFor given number N you must output amount of N-digit numbers, such, that last digits of their square is equal to 987654321.InputInput contains integer number N (1<=N<=106)OutputWrite answer to the output.Sample In 阅读全文

posted @ 2013-03-16 23:33 仗剑奔走天涯 阅读(175) 评论(0) 推荐(0)

SGU115 - Calendar
摘要:115. Calendartime limit per test: 0.5 sec.memory limit per test: 4096 KBFirst year of new millenium is gone away. In commemoration of it write a program that finds the name of the day of the week for any date in 2001.InputInput is a line with two positive integer numbersNandM, whereNis a day number 阅读全文

posted @ 2013-03-16 21:46 仗剑奔走天涯 阅读(178) 评论(0) 推荐(0)

SGU104 - Little shop of flowers
摘要:104. Little shop of flowerstime limit per test: 0.5 sec.memory limit per test: 4096 KBPROBLEMYou want to arrange the window of your flower shop in a most pleasant way. You haveFbunches of flowers, each being of a different kind, and at least as many vases ordered in a row. The vases are glued onto t 阅读全文

posted @ 2013-03-13 23:26 仗剑奔走天涯 阅读(262) 评论(0) 推荐(0)

SGU106 - The equation
摘要:106. The equationtime limit per test: 0.5 sec.memory limit per test: 4096 KBThere is an equation ax + by + c = 0. Given a,b,c,x1,x2,y1,y2 you must determine, how many integer roots of this equation are satisfy to the following conditions : x1<=x<=x2, y1<=y<=y2. Integer root of this equat 阅读全文

posted @ 2013-03-12 23:55 仗剑奔走天涯 阅读(373) 评论(0) 推荐(0)

SGU123 - The sum
摘要:123. The sumtime limit per test: 0.5 sec.memory limit per test: 4096 KBThe Fibonacci sequence of numbers is known: F1= 1; F2= 1; Fn+1= Fn+ Fn-1, for n>1.You have to findS- the sum of the firstKFibonacci numbers.InputFirst line contains natural numberK(0<K<41).OutputFirst line should contain 阅读全文

posted @ 2013-03-12 09:06 仗剑奔走天涯 阅读(180) 评论(0) 推荐(0)

SGU105 - Div 3
摘要:105. Div 3time limit per test: 0.5 sec.memory limit per test: 4096 KBThere is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3.InputInput contains N (1<=N<=231- 1).OutputWrite answer t 阅读全文

posted @ 2013-03-11 17:30 仗剑奔走天涯 阅读(176) 评论(0) 推荐(0)

SGU101 - 200分类
摘要:101 Domino 欧拉路102 Coprime 枚举/数学方法103 Traffic Lights 最短路104 Little Shop of Flowers 动态规划105 Div 3 找规律106 The Equation 扩展欧几里德107 987654321 Problem 找规律108 Self-numbers II 枚举+筛法递推109 Magic of David Copperfield II 构造110 Dungeon 计算几何+模拟111 Very Simple Problem 模拟笔算开方112 a^b-b^a 高精度113 Nearly Prime Numbers 判 阅读全文

posted @ 2013-03-10 01:49 仗剑奔走天涯 阅读(263) 评论(0) 推荐(0)

SGU112 - a^b-b^a
摘要:112. ab-batime limit per test: 0.5 sec.memory limit per test: 4096 KBYou are given natural numbers a and b. Find ab-ba.InputInput contains numbers a and b (1≤a,b≤100).OutputWrite answer to output.Sample Input2 3Sample Output-1题解:高精度乘法和高精度减法。水水的。。。不过第五个数据WA了,不知道为什么,是用函数memcmp去判断两个数组所代表的数的大小,莫名其妙的出错了, 阅读全文

posted @ 2013-03-08 19:18 仗剑奔走天涯 阅读(231) 评论(0) 推荐(0)

SGU102 - Coprimes
摘要:102. Coprimestime limit per test: 0.5 sec.memory limit per test: 4096 KBFor given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprime with N. Let us call two positive integers (say, A and B, for example) coprime if (and only if) their greatest common divisor i 阅读全文

posted @ 2013-03-08 03:32 仗剑奔走天涯 阅读(141) 评论(0) 推荐(0)

SGU101 - Domino
摘要:101. Dominotime limit per test: 0.5 sec.memory limit per test: 4096 KBDominoes – game played with small, rectangular blocks of wood or other material, each identified by a number of dots, or pips, on its face. The blocks usually are called bones, dominoes, or pieces and sometimes men, stones, or eve 阅读全文

posted @ 2013-03-08 03:06 仗剑奔走天涯 阅读(305) 评论(0) 推荐(0)

导航