洛谷试炼场

第一个任务

//a+b就不打了 新手试水题233

P1421 小玉买文具

简单模拟问题 把a元b角全部转化为角后就可以容易地解决了

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,n;
    cin>>a>>b;
    n=10*a+b;
    cout<<n/19;
    return 0; 
}
View Code

P1425 小鱼的游泳时间

简单模拟问题 主要是通过模拟竖式减法来求解

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define inf 10e8
using namespace std;
int a,b,c,d,e,f;

int main(int argc, const char * argv[])
{
    cin>>a>>b>>c>>d;
    f=d-b;
    e=c-a;
    //模拟竖式减法
    if(f<0)
    {
        f+=60;
        e--;
    }
    //模拟当前位不够减则借位相减
    cout<<e<<" "<<f;
    puts("");
    return 0;
}
View Code

猜你喜欢

转载自www.cnblogs.com/gc812/p/9298312.html