第 2 届河北省大学生程序设计竞赛(河北省赛)-Problem C. icebound 的账单-题解

传送门

Problem A. Mex Query

Problem B. Nim Game

Problem C. icebound 的账单

Problem G. 520

Problem H. 神殿

Problem J. icebound 的商店

Problem K. Bitmap

       哈希讲解
       二维哈希讲解

Problem L. 跑图

文章目录

  • 传送门
        • Problem A. Mex Query
        • Problem B. Nim Game
        • Problem C. icebound 的账单
        • Problem G. 520
        • Problem H. 神殿
        • Problem J. icebound 的商店
        • Problem K. Bitmap
            •        哈希讲解
            •        二维哈希讲解
        • Problem L. 跑图
  • Problem C. icebound 的账单
      • Description
      • Input
      • Output
      • Sample Input
      • Sample Output
    • 题目大意
    • 解题思路
    • AC代码





Problem C. icebound 的账单

Time Limit: 1000ms
Memory Limit: 65536KB

Description

icebound从小就有记账的习惯。又到了月末icebound统计资金状况的时候。icebound每个月除了不停的挥霍以外,有时他会良心发现,勤工俭学,因此会有一些微薄的收入。然而icebound数学不好,需要你来帮助他统计他本月的资金状况。

你将会得到一份icebound的账单,一共有 n​ 行整数,其中正数表示icebound打工挣来的收入,负数表示icebound消费的支出。数据保证不会出现 0​ 。

如果icebound本月总收入大于总支出,请你输出“icebound is happy.”;如果本月总收入等于总支出,请你输出“icebound is ok.";如果总收入小于总支出,请你输出"icebound is sad."。

Input

第一行,有一个正整数 n n n,代表账单有 n n n行。

接下来有 n n n行,每行一个整数,第 i + 1 i+1 i+1行整数 a i a_i ai

1 ≤ n ≤ 1000 , ∣ a i ∣ ≤ 1000 , a i ≠ 0 1\leq n\leq 1000, |a_i|\leq 1000, a_i\neq0 1n1000,ai1000,ai=0

Output

输出一行。如果icebound本月总收入大于总支出,请你输出“icebound is happy.”;如果本月总收入等于总支出,请你输出“icebound is ok.";如果总收入小于总支出,请你输出"icebound is sad."。

Sample Input

2
100
-100

Sample Output

icebound is ok.

题目大意

给你 n n n个数代表icebound的收入支出记录,问你到最后icebound有攒到钱了,收支平衡,还是欠钱了。


解题思路

累加之后与0比较即可。

AC代码

#include
using namespace std;
typedef long long ll;

int main()
{
     
    int n;
    cin>>n;
    ll s=0;//其实不long long也无所谓
    for(int i=0;i<n;i++)
    {
     
        ll t;
        cin>>t;
        s+=t;
    }
    if(s>0)puts("icebound is happy.");
    else if(s)puts("icebound is sad.");
    else puts("icebound is ok.");
    return 0;
}

原创不易,转载请附上原文链接哦~
Tisfy:https://letmefly.blog.csdn.net/article/details/116504142

你可能感兴趣的:(题解,#,河北省赛,题解)