Shirlies
宁静专注认真的程序媛~
摘要: #include "stdio.h"#include "math.h"int is_prim(int n){int i;for(i=2;i<=sqrt(n);i++)//晕,这里用i*i<=n就超时了,没有头绪,莫名其妙,网上看了别人的代码,就将它改成这样,竟然A了,汗~~~……………………哈,忽然想到是为什么了,理由是:当循环到i=46340时i*i<n;但i=46341时i*i=2147488281,超过了int的最大值,溢出变成负数,仍然满足i*i<n!n不是太大的话,运气好还能碰上101128442溢出后等于2147483 阅读全文
posted @ 2012-01-17 23:12 Shirlies 阅读(323) 评论(0) 推荐(0) 编辑
摘要: #include "iostream"#include "stdlib.h"#include "string.h"typedef struct{int p;int w;}rice;int cmp(const void *a,const void *b){ rice *c=(rice *)a; rice *d=(rice *)b;return c->p-d->p;}int main(){int n,m;int c;rice r[1005];scanf("%d",&c);while(c--){sca 阅读全文
posted @ 2012-01-17 21:47 Shirlies 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionAcmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz him. But Orz him is not that easy.You must solve this problem first.The problem is :Give you a sequence of distinct integers, choose 阅读全文
posted @ 2012-01-17 21:08 Shirlies 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 贪心题Problem Description“Point, point, life of student!”This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.There are 5 problems in this final exam. And I will give you 100 阅读全文
posted @ 2012-01-17 20:41 Shirlies 阅读(819) 评论(0) 推荐(0) 编辑