
Sicily Online Judge
yzl_rex
这个作者很懒,什么都没留下…
展开
-
sicily 1134
#include #include #include using namespace std;struct Info{ int a; int b;};bool comp (const Info &temp1, const Info &temp2){ return temp1.b < temp2.b;}int main(){ i原创 2011-12-09 00:06:15 · 755 阅读 · 0 评论 -
sicily 1691
#include "iostream"#include "algorithm"using namespace std;int main(){ int TestCase; cin >> TestCase; while (TestCase--) { int range1, range2, tag = 0, abundance[1024] = {0}; c原创 2011-12-03 08:19:00 · 467 阅读 · 0 评论 -
sicily 1701
#include "iostream"using namespace std;int main(){ int TestCase, Case = 0; cin >> TestCase; while (TestCase--) { Case++; int Num, sum1 = 0, sum2 = 0; cin >> Num; sum1 =原创 2011-12-02 12:19:33 · 865 阅读 · 0 评论 -
sicily 1342 (0/1背包问题)
//首次接触背包问题,理解起来还是有点吃力!需要多练习! #include "iostream"#include "cmath"using namespace std;int total[26][300010];int main(){ int N, m; while (cin >> N >> m) { int *price = new int[m+1];原创 2011-11-10 00:04:29 · 591 阅读 · 0 评论 -
sicily 1752
#include "iostream"#include "cmath"#include "map"using namespace std;bool is_primer(int n){ if (n == 1) return false; int m = floor(sqrt(double (n)) + 0.5); for (int i = 2; i <= m原创 2011-11-30 15:54:25 · 449 阅读 · 0 评论 -
sicily 1341
//while(1)//{//cin >> n;//}//和//while(cin >> n)//{//}//的区别很重要,时间有很大的差距!#include "iostream"#include "set"using namespace std;int main(){ int N; while (cin >> N) { set原创 2011-11-09 00:05:47 · 520 阅读 · 0 评论 -
sicily 1259
#include "iostream"#include "math.h"#include "vector"using namespace std;int is_prime(int x);//判断一个数是否为素数int main(){ int ans, count = 0; vector v;//用一个容器来装素数 while (cin >> ans && ans原创 2011-11-08 19:53:35 · 730 阅读 · 0 评论 -
sicily 1765
#include "iostream"#include "string"#include "algorithm"#include "cmath"using namespace std;bool is_primer(int n)//判断是否为质数{ if (n == 1) return false; int m = floor(sqrt(double (n)) +原创 2011-11-30 10:35:17 · 431 阅读 · 0 评论 -
sicily 1757
#include "iostream"#include "string"#include "cctype"#include "sstream"using namespace std;int main(){ int T; cin >> T; while (T--) { string str[5];//保存输入的字符串 int a[5] = {0原创 2011-11-30 10:01:55 · 1020 阅读 · 0 评论 -
sicily 1753
#include "iostream"#include "cctype"#include "string"#include "sstream"using namespace std;int main(){ string str; while (cin >> str && str != "XXX") { int size; size = str.s原创 2011-11-30 00:32:18 · 444 阅读 · 0 评论 -
sicily 1931
//利用两个队列就可以解决问题,一个出队,一个入队!//但是就开始的时候我没有考虑到当输入的牌数小于或等于2的情况,所以WA了一次!#include "iostream"#include "deque"using namespace std;int main(){ int TestCase; cin >> TestCase; while (TestCase-原创 2011-11-29 13:14:05 · 580 阅读 · 0 评论 -
sicily 1176
#include "iostream"#include "memory.h"using namespace std;int Num[1010];//存储输入的数字int ans[1010][1010];//对每一次决策后结果的存储!int dp(int a, int b);//动态规划方法的实现int main(){ int n, count = 0;原创 2011-11-29 12:39:31 · 1108 阅读 · 0 评论 -
sicily 1306
#include "iostream"#include "set"#include "algorithm"using namespace std;int main(){ int n, m; /*multiset s; multiset::iterator it;*/ while (cin >> n >> m && m != 0 && n != 0) {原创 2011-11-08 21:28:58 · 543 阅读 · 0 评论 -
sicily 1022
//在做这一题的时候,我刚开始是用STL中的set容器来做,很快就得到了答案,但提交上去就超时!//再分析一下set中的数据结构,原来是红黑树,要的时间复杂度是O(n),所以就需要寻找一个时间//复杂度更小的,所以只有堆了(二叉树),其时间复杂度为O(logn)!但当我用堆来完成的时候,由于//使用了c++的输入输出方法,即cin和cout,又超时了!只有再换回c语言中的scanf和p原创 2011-12-02 09:22:57 · 1233 阅读 · 0 评论 -
sicily 1198
#include "iostream"#include "string"#include "algorithm"using namespace std;bool comp(string s1, string s2){ return s1 + s2 < s2 + s1;//这样的比较就可以避免c,ca这种情况的出现判断!输出的是cac,而不是cca!}int main原创 2011-11-12 00:43:51 · 868 阅读 · 0 评论 -
sicily 1157
#include "iostream"#include "set"using namespace std;struct comp{ bool operator() (const int &a, const int &b) { if (a != b) return a > b; else return a > b; }};int原创 2011-12-08 22:57:30 · 527 阅读 · 0 评论 -
sicily 1817
#include "iostream"#include using namespace std;const int Max = 100;int main(){ int TestCase; //cin >> TestCase; scanf("%d", &TestCase); while (TestCase--) { int score[Max原创 2011-12-08 22:43:39 · 833 阅读 · 0 评论 -
sicily 1625
#include "iostream"#include "bitset"#include "string"#include "sstream"using namespace std;int main(){ int TestCase; cin >> TestCase; int Case = 0; while (TestCase--) { Case原创 2011-12-05 22:32:03 · 434 阅读 · 0 评论 -
sicily 1793
//自己做了很久也没有做出来,或者数学太差了,想不到思路!这题是我在百度上搜到比较简洁的做法,所以自己看明白之后再重新实现一次的!//设x=GCD(a,b),y=LCM(a,b)。//a=x*k1//b=x*k2, 其中 GCD(k1,k2)=1//有y=x*k1*k2;//求min(a,b),即min(k1,k2)//有k1和k2两个未知数,数据规模也不是特别大,可以用搜转载 2011-12-06 18:43:55 · 513 阅读 · 0 评论 -
sicily 1741
#include "iostream"#include "iomanip"using namespace std;struct Info{ int X; int Y;};double area(double a, double b, double c, double d){ double differX = c - a;原创 2011-12-05 09:30:57 · 413 阅读 · 0 评论 -
sicily 1738
//就开始的时候我看了很久都没有看明白题目,不知道它按什么来进行排序的,到最后,看了很久才看明白,//它的得分是唯一的,所以就通过其得分来进行排序!#include "iostream"#include "algorithm"using namespace std;struct contest{ int ID; int Scores; int Penalty原创 2011-12-04 20:45:52 · 523 阅读 · 0 评论 -
sicily 1624
#include "iostream"#include "map"#include "string"using namespace std;int main(){ int TestCase; cin >> TestCase; cin.get(); int Case = 0; while (TestCase--) { Case++; str原创 2011-12-04 16:37:39 · 437 阅读 · 0 评论 -
sicily 1761
//做这题的时候,最开始我是用字符串来做的,但是AC不了,然后再参照别人的代码用char来做,//还是没有AC,搞了我大半天,原来是我没有将验证码为X的这种情况考虑进去!哎!#include "iostream"#include "string"#include "sstream"using namespace std;int main(){ string st原创 2011-12-04 15:50:12 · 447 阅读 · 0 评论 -
sicily 1689
#include "string"#include "set"using namespace std;struct Info{ int times; string ID; string Status;};int main(){ int T; cin >> T; while (T--) {原创 2011-12-05 08:25:16 · 601 阅读 · 0 评论 -
sicily 1608
#include "iostream"#include "string"#include "sstream"using namespace std;int main(){ int TestCase; cin >> TestCase; while (TestCase--) { int N; cin >> N; string str = "";原创 2011-12-03 16:58:55 · 540 阅读 · 0 评论 -
sicily 1634
//这道题看上去貌似要计算很多东西,其实不用的,要记住刘汝佳老师讲的一句话:在ACM中,//有很多题目要的是一种答案,而不是过程,所以不需将问题想得太复杂!//不过,如果想要学东西,还是需要老老实实的做,注重下过程!#include "iostream"using namespace std;int main(){ int a, b; while (cin >>原创 2011-12-03 16:27:17 · 577 阅读 · 0 评论 -
sicily 1712
#include "iostream"#include "string"using namespace std;int main(){ string Input; while (cin >> Input && Input != "#") { int size = Input.size(); int count = 0; for (int i = 0原创 2011-12-02 12:45:36 · 392 阅读 · 0 评论 -
sicily 1240
//利用最原始,最容易懂的方法:通过计算出加多的路程,然后将显示的路程减去加多的路程就得到实际的路程!其过程利用到递推的关系!#include "iostream"using namespace std;int main(){ int n; while (cin >> n && n != 0) { int temp1 = n, temp2 = n, count =原创 2011-11-10 19:18:06 · 835 阅读 · 0 评论 -
sicily 1388
#include "iostream"#include "map"#include "string"using namespace std;int main(){ map m;//定义一个map容器 m[' '] = 0; m['A'] = 1; m['B'] = 2; m['C'] = 3; m['D'] = 4; m['E'] = 5; m['F'] = 6; m[原创 2011-11-08 00:06:23 · 509 阅读 · 0 评论 -
sicily 1294
//一道公式题目,如果不懂公式,很难做!公式:(a*b) mod c=a*(b mod c) mod c #include using namespace std; int main() //两次求余数就可以!{ int a, b, c; cin >> a >> b >> c; int s = a % c; for(int i原创 2011-11-07 19:41:39 · 568 阅读 · 0 评论 -
sicily 1561
#include "iostream"#include "cmath"using namespace std;bool is_primer(int n){ if (n == 1) return false; int b = floor(sqrt(double(n))+0.5); for (int i = 2; i <= b; i++) if (n % i原创 2011-11-21 17:00:54 · 686 阅读 · 0 评论 -
sicily 1194
#include "iostream"#include "string"#include "ctype.h"#include "set"using namespace std;string transform(string &s)//将输入的字符串统一转换为大写又或者为小写,要不结果的输出格式就有问题{ int length = s.size(); string s原创 2011-11-01 20:37:00 · 1192 阅读 · 0 评论 -
sicily 1433
#include "iostream"#include "algorithm"using namespace std;int main(){ int TestCase; cin >> TestCase; while (TestCase--) { int StoreNum, distance = 0; cin >> StoreNum; int *po原创 2011-11-21 22:11:19 · 681 阅读 · 0 评论 -
sicily 1482
//就开始的时候在格式的输出有错误,实在是搞不懂“两个相邻测试数据间用一个空行隔开”如何表示,看了别人的代码才明白!#include "iostream"#include "algorithm"using namespace std;struct Info//学生信息的存储{ int num; int chinese; int math; int engli原创 2011-11-21 23:52:30 · 576 阅读 · 0 评论 -
sicily 1443
#include "iostream"#include "deque"using namespace std;struct Info//job的位置和优先权的信息{ int num; int pr;};int main(){ int n; cin >> n; deque d; while (n--) { d.clear();原创 2011-11-21 10:22:20 · 1021 阅读 · 0 评论 -
sicily 1510
#include "iostream"#include "string"using namespace std;struct Info{ int pos; string str;};int main(){ int N; cin >> N; Info *s = new Info[N]; for (int i = 0; i < N; i++)原创 2011-11-21 12:43:29 · 463 阅读 · 0 评论 -
sicily 1144
超级水题!!!#include "iostream"using namespace std;int main(){ int a[10], height, count = 0; for (int i = 0; i < 10; i++) cin >> a[i]; cin >> height; for (int i = 0; i < 10; i++) if ((h原创 2011-11-01 08:36:25 · 365 阅读 · 0 评论 -
sicily 1381(高精度)
#include "iostream"#include "string"#include "string.h"#include "sstream"using namespace std;int main (){ int T; string str1, str2;//输入的两个整数用字符串来表示 cin >> T; while (T--) { cin原创 2011-11-01 08:26:20 · 674 阅读 · 0 评论 -
sicily 1027
#include "iostream"#include "string"using namespace std;int main(){ int n; while (cin >> n) { if (n == 0) break; string *str = new string [n]; for (int i = 0; i < n; i++)//字符串的原创 2011-10-31 17:58:20 · 637 阅读 · 0 评论 -
sicily 1007
#include "iostream"#include "string"#include //使用reverse时候,这个头文件需要包含!using namespace std;int main(){ int n, length; string str; while (cin >> n )//输入columns { if (n != 0) {原创 2011-10-28 21:02:01 · 717 阅读 · 0 评论