HDU100题 2090-2099

2090:

#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string name;
    double cnt, price;
    double sum = 0;
    while(cin >> name >> cnt >> price)
    {
        sum += cnt * price;
    }
    printf("%.1lf\n", sum);


    return 0;
}

2091:

// ...

2092:

#include <cstdio>
#include <cmath>

using namespace std;


int main()
{   
    int n, m;
    while(scanf("%d %d", &n, &m), n+m)
    {
        int diet = n*n - 4*m;
        // printf("diet = %d\n", diet);
        if(diet < 0)
            printf("No\n");
        else
        {
            int x1 = (n + sqrt(diet)) / 2;
            int x2 = (n - sqrt(diet)) / 2;
            int y1 = n - x1;
            int y2 = n - x2;
            // printf("x1=%d y1=%d\n", x1, y1);
            // printf("x2=%d y2=%d\n", x2, y2);
            if(x1 + y1 == n && x1 * y1 == m || x2 + y2  == n && x2 * y2 == m)
                printf("Yes\n");
            else 
                printf("No\n");
        }
        
    }


    return 0;
}

2093:

// ...

2094:

#include <bits/stdc++.h>

using namespace std;

map<string, int> ma;
set<string> s;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie();
    int n;
    while(cin >> n, n)
    {
        ma.clear();
        s.clear();
        string a, b;

        for(int i=0; i<n; i++)
        {
            cin >> a >> b;
            s.insert(a);
            s.insert(b);
            ma[b] ++;
        }
        if(s.size() - ma.size() == 1)
            cout << "Yes" << endl;
        else 
            cout << "No" << endl;
    }


    return 0;
}

2095:

#include <bits/stdc++.h>

using namespace std;
const int N = 1000010;
typedef pair<int, int> P;

map<int, int> mp;
vector<P> ve;

bool cmp(P p1, P p2)
{
    return p1.second < p2.second;
}

int main()
{
    int n;
    while(scanf("%d", &n), n)
    {
        mp.clear();
        ve.clear();
        int num;
        for(int i=0; i<n; i++)
        {
            scanf("%d", &num);
            mp[num] ++;
        }
        int len = mp.size();
        P p;
        map<int, int>::iterator it;
        for(it = mp.begin(); it != mp.end(); it++)
        {
            ve.push_back(P(it->first, it->second));
        }
        sort(ve.begin(), ve.end(), cmp);
        printf("%d\n", ve[0].first);
    }    


    return 0;
}

2096:

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;


int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        LL a, b;
        scanf("%lld %lld", &a, &b);

        printf("%lld\n", (a+b) % 100);
    }


    return 0;
}

2097:

#include <bits/stdc++.h>

using namespace std;

stack<int> s12;
stack<int> s16;


void trans12(int x)
{
    while(!s12.empty()) s12.pop();
    while(x)
    {
        s12.push(x%12);
        x /= 12;
    }
}

void trans16(int x)
{
    while(!s16.empty()) s16.pop();
    while(x)
    {
        s16.push(x%16);
        x /= 16;
    }
}


int main()
{
    int n;
    while(scanf("%d", &n), n)
    {
        int x = n;
        int sum10 = 0;
        int sum12 = 0;
        int sum16 = 0;

        while(x)
        {
            sum10 = sum10 + x%10;
            x /= 10;
        }
        trans12(n);
        trans16(n);
        while(!s12.empty())
        {
            sum12 += s12.top();
            s12.pop();
        }
        while(!s16.empty())
        {
            sum16 += s16.top();
            s16.pop();
        }
        if(sum10 == sum12 && sum12 == sum16)
        {
            printf("%d is a Sky Number.\n", n);
        }
        else 
            printf("%d is not a Sky Number.\n", n);
    }


    return 0;
}

2098:

#include <bits/stdc++.h>

using namespace std;
const int N = 10010;

int prime[N];

void init()
{
    prime[0] = prime[1] = 1;
    int len = sqrt(N+1);
    for(int i=2; i<len; i++)
    {
        if(!prime[i])
            for(int j=i+i; j<N; j += i)
                prime[j] = 1;
    }
}

int main()
{
    init();
    int num;
    while(scanf("%d", &num), num)
    {
        int ans = 0;
        int i = 1, j = num - 1;
        while(i < j)
        {
            if(i + j == num && !prime[i] && !prime[j])
            {
                ans ++;
                i ++;
                j --;
            }
            else if(i + j < num)
                i++;
            else 
                j--;
        }
        printf("%d\n", ans);
    }



    return 0;
}

2099:

#include <bits/stdc++.h>

using namespace std;

vector<int> ve;

int main()
{
    int a, b;
    while(scanf("%d %d", &a, &b), a+b)
    {
        ve.clear();
        for(int i=0; i<100; i++)
        {
            if((a * 100 + i) % b == 0)
                ve.push_back(i);
        }
        int vlen = ve.size();
        for(int i=0; i<vlen; i++)
        {
            if(ve[i] < 10)
                printf("0%d%c", ve[i], i == vlen-1 ? '\n' : ' ');
            else
                printf("%d%c", ve[i], i == vlen-1 ? '\n' : ' ');
        }
    }


    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值