POJ 4011

3 篇文章 0 订阅

ACM ICPC 2011–2012, NEERC, Northern Subregional Contest
St Petersburg, October 29, 2011
Problem A. Automated Telephone Exchange

Input file: ate.in
Output file: ate.out
Time limit: 3 seconds
Memory limit: 256 megabytes
In St Petersburg phone numbers are formatted as “XXX–XX–XX”, where the first three digits represent index of the Automated Telephone Exchange (ATE). Each ATE has exactly 10 000 unique phone numbers.
Peter has just bought a new flat and now he wants to install a telephone line. He thinks that a phone number is lucky if the arithmetic expression represented by that phone number is equal to zero. For example, the phone number 102–40–62 is lucky (102 – 40 – 62 = 0), and the number 157–10–47 is not lucky (157 – 10 – 47 = 100 ≠ 0).
Peter knows the index of the ATE that serves his house. To get an idea of his chances to get a lucky number he wants to know how many lucky numbers his ATE has.
Input
The input file contains a single integer number n — the index of Peter’s ATE (100 ≦ n ≦ 999).
Output
Output a single integer number — the number of lucky phone numbers Peter’s ATE has.
Examples

ate.inate.out
1963
2390


水题:

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n) != EOF)
    {
      int ans = 0;
      if(n >= 199)
      printf("0\n");
      else
      {
        if(n % 2 == 0)
        {
          ans = 1+ 2*(99 - n/2);
        }
        else
        {
          ans = 2*(100 - (n+1)/2);
        }
        printf("%d\n", ans);
      }
    }
    return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值