zoukankan      html  css  js  c++  java
  • HDU 1030 1031

    HDU 1030 Delta-wave

    题意:略;
    思路:参考的别人的思路,看这里

    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cstdlib>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    int main()
    {
    	int n,m;
    	while(scanf("%d%d",&n,&m)!=EOF)
    	{
    		int cn=(int )ceil(sqrt(n));//ceil为向上取整函数;
    		int cm=(int )ceil(sqrt(m));
    		int ln=(cn*cn-n)/2+1;
    		int lm=(cm*cm-m)/2+1;
    		int rn=(n-(cn-1)*(cn-1)-1)/2+1;
    		int rm=(m-(cm-1)*(cm-1)-1)/2+1;
    		int ans=abs(cn-cm)+abs(ln-lm)+abs(rn-rm);
    		printf("%d
    ",ans);
    	}
    	return 0;
    }  
    

    HDU 1031 Design T-Shirt

    题意:n个人给m见作品投票,取前k名;
    思路:两次快排;

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cmath>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    struct node
    {
    	int mark;
    	double num;
    };
    node a[100000];
    bool cmp1(node aa,node bb)
    {
    	if(aa.num==bb.num) return aa.mark<bb.mark;
    	else return aa.num>bb.num; 
    }
    bool cmp2(node aa,node bb)
    {
    	return aa.mark>bb.mark; 
    }
    int main()
    {
    	int n,m,k;
    	while(scanf("%d%d%d",&n,&m,&k)!=EOF)
    	{
    		for(int i=1; i<=m; i++){
    			scanf("%lf",&a[i].num);
    			a[i].mark=i;
    		}
    		for(int i=1; i<n; i++)
    		for(int j=1; j<=m; j++){
    			double x;
    			scanf("%lf",&x);
    			a[j].num+=x;
    		}
    		
    		sort(a+1,a+m+1,cmp1);
    		sort(a+1,a+k+1,cmp2);
    		for(int i=1; i<k; i++)
    		 printf("%d ",a[i].mark);
    		printf("%d
    ",a[k].mark);
    	}
    	return 0;
    }
  • 相关阅读:
    hero
    今年暑假不AC
    Who's in the Middle
    A Simple Problem with Integers
    I hate it
    敌兵布阵
    Ordering Tasks
    Points on Cycle
    食物链
    c++ 14.0下载地址
  • 原文地址:https://www.cnblogs.com/zzulipomelo/p/5287047.html
Copyright © 2011-2022 走看看