码迷,mamicode.com
首页 > 其他好文 > 详细

DAY 4

时间:2019-06-29 22:04:36      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:%s   ring   fine   har   lse   sort   break   const   algo   

A

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define ll long long

const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;

int main()
{
    int a,b,c,d,e;
    while(~scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)) {
        int sum = a * b * c;
        if (d < e) {
            sum -= 2 * ((a - 2 * e) * (c - 2 * e) * d + (a - 2 * e) * (b - 2 * e) * d + (b - 2 * e) * (c - 2 * e) * d);
            cout << sum << endl;
        } else {
            int tot1 = ((a - 2 * e) * e * e * 4 + (b - 2 * e) * e * e * 4 + (c - 2 * e) * e * e * 4 + e * e * e * 8);
            int tot2 = (a - 2 * d) * (b - 2 * d) * (c - 2 * d);
            cout << max(tot1,tot2) << endl;
        }
    }
}

 B

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;

const int maxn = 1e4+7;
int arr[maxn],mtx[10007][107];



int main()
{
    int t,N,n,m,i=0;
    scanf("%d",&t);
    while(t--)
    {
        i = 0;
        scanf("%d",&N);
        n = sqrt(N*1.0);
        while(N%n) n--;
        m = N/n;
        for(int i=0;i<N;i++) scanf("%d",&arr[i]);
        sort(arr,arr+N,greater<int>());
        arr[N] = 0;

        int pos = 0;
        int cot = 0;
        while(pos < N)
        {
            for(int j=cot;j<n-cot && pos<N;j++)
                mtx[cot][j] = arr[pos++];
            for(int j=cot+1;j<m-cot && pos<N;j++)
                mtx[j][n-1-cot] = arr[pos++];
            for(int j=n-2-cot;j>=cot && pos<N;j--)
                mtx[m-1-cot][j] = arr[pos++];
            for(int j=m-2-cot;j>cot && pos<N;j--)
                mtx[j][cot] = arr[pos++];
            cot++;
        }
        for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
                j == n-1 ? printf("%d\n",mtx[i][j]) : printf("%d ",mtx[i][j]);
        printf("\n");
    }
}

 C

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;

const int maxn = 1e4+7;

char Time[10];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,Ta,b,Tb;
        int h,m;
        scanf("%d %d",&a,&Ta);
        scanf("%d %d",&b,&Tb);

        scanf("%s",Time);
        h = (Time[0] - ‘0‘ )* 10 + Time[1] - ‘0‘;
        m = (Time[3] - ‘0‘ )* 10 + Time[4] - ‘0‘;
        int tot = h * 60 + m;
        int st =  tot - Tb;
        int en = tot + Ta;
        //printf("%d %d\n",st,en);
        int ans = 0;
        for(int i=300;i<=23 * 60 + 59;i += b)
        {
            if(i > st && i < en) {
                ans++;
                //cout<<i<<endl;
            }
        }
        printf("%d\n",ans);
    }
}

 D

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;

const int maxn = 1e4+7;


int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int x;
        int tot = 0;
        int ans = 0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            if(x > 0)
                tot += x/2;
            else
                tot += x;
            if(tot < 0)
                ans++;
        }
        printf("%d\n",ans);
    }
}

 E

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define ll long long

const int maxn = 1e2 + 10;
const int INF = 0x3f3f3f3f;

double a[maxn][maxn];

int main()
{
    int n,k;
    double m;
    while(~scanf("%d %lf %d",&n,&m,&k)) {
        vector<int>v[maxn];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                scanf("%lf", &a[i][j]);
                if (a[i][j] >= m) {
                    v[i].push_back(j);
                }
            }
        }
        int ans = 0,anss;
        while(true)
        {
            anss = ans;
            ans = 0;
            for(int i=0;i<n;i++)
            {
                for(int j=i+1;j<n;j++)
                {
                    int tot = 0;
                    if(a[i][j] < m)
                    {
                        for(int k=0;k<v[i].size();k++)
                        {
                            for(int kk = 0;kk < v[j].size();kk++)
                            {
                                if(v[i][k] == v[j][kk])
                                    tot++;
                            }
                        }
                        if(tot >= k)
                        {
                            ans ++;
                            v[i].push_back(j);
                            v[j].push_back(i);
                        }
                    }
                }
            }
            if(ans == anss)
                break;
        }
        printf("%d\n",ans);
    }
}

 F

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define ll long long

const int maxn = 1e2 + 10;
const int INF = 0x3f3f3f3f;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int flag = 0;
        double a,b,sum = 0;
        int x;
        scanf("%lf %lf %d",&a,&b,&x);
        while(sum < x)
        {
            int k = ceil(a/b - 1);
            double dx = (a - b * k) / (2 * k + 1);
            dx = min(dx,x - sum);
            a -= dx * (2 * k + 1);
            sum += dx;
            if(a < b && sum + b < x)
            {
                flag = 1;
                break;
            }
        }
        if(flag)
            puts("-1");
        else
            printf("%.5f\n",a);
    }
}

 G

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define ll long long

const int maxn = 1e2 + 10;
const int INF = 0x3f3f3f3f;

int main()
{
    int a,b;
    cin >> a >> b;
    if(a > 0)
        b = -1 * b;
    else
        b *= 2;
    if(b * b % 2 == 1)
    {
        if(b < 0 && a > 0)
            a = -1 * a;
        if(b > 0 && a < 0)
            a = -1 * a;
    }
    else
    {
        if(b < 0 && a < 0)
            a = -1 * a;
        if(b > 0 && a > 0)
            a = -1 * a;
    }
    printf("%d\n",a - b);
}

 H

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define ll long long

const int maxn = 1e2 + 10;
const int INF = 0x3f3f3f3f;

int main()
{
    int a;
    double b;
    cin >> a >> b;
    printf("%d %.2f\n",a,b);
}

 

DAY 4

标签:%s   ring   fine   har   lse   sort   break   const   algo   

原文地址:https://www.cnblogs.com/smallhester/p/11107962.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!