摘要: 这个题是个数学题;2n个数,要求n个向上取整,n个向下取整,然后要求最后的数列之和与初始数列之和的差异最小;差异di=(1-ai)-(bi-0);容易看出ai与bi 的符号相同,故可以一次性将他们全部处理掉;最后用一个整数减去上面一步得到的数;得到的最小值就是我们所需要的;代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 int n,cnt; 6 double x,ans; 7 int main() 8 { 9 scanf("%d",&n);10 double res=99999999;11 阅读全文
posted @ 2013-10-13 16:15 Yours1103 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 很简单的一个题;只需要将他们排一下序,然后判断一下就可以了!代码: 1 #include 2 #include 3 #define maxn 100005 4 using namespace std; 5 6 int n,x; 7 int a[maxn][2],cot; 8 struct node 9 {10 int v,id;11 bool operator<(node const &t)const12 {13 if(v==t.v)return id<t.id;14 return v<t.v;15 }16 } no[maxn]... 阅读全文
posted @ 2013-10-13 16:10 Yours1103 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 超级大水题;只要用到一个小学用过的结论就可;能被9整除的数它的各位数相加能被9整除:代码: 1 #include 2 #define maxn 1005 3 using namespace std; 4 int n,c0,c5,x; 5 int main() 6 { 7 cin>>n; 8 while(n--) 9 {10 cin>>x;11 if(x==0)c0++;12 else c5++;13 }14 if(c0==0){cout<<"-1";return 0;}15 c5=c5-c5%9;1... 阅读全文
posted @ 2013-10-13 16:08 Yours1103 阅读(176) 评论(0) 推荐(0) 编辑