zoukankan      html  css  js  c++  java
  • Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things

    链接:

    https://codeforces.com/contest/1247/problem/A

    题意:

    Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation a+1=b with positive integers a and b, but Kolya forgot the numbers a and b. He does, however, remember that the first (leftmost) digit of a was da, and the first (leftmost) digit of b was db.

    Can you reconstruct any equation a+1=b that satisfies this property? It may be possible that Kolya misremembers the digits, and there is no suitable equation, in which case report so.

    思路:

    特判9 1,其他的照着搞。

    代码:

    //#include <iostream>
    //#include <fstream>
    //#include <process.h>
    //#include "ch08/ch08Func.cpp"
    #include <bits/stdc++.h>
    typedef long long LL;
    using namespace std;
     
    int main()
    {
        ios::sync_with_stdio(false);
        int a, b;
        cin >> a >> b;
        if (a == b)
        {
            cout << a << '1' << ' ' << b << '2' << endl;
            return 0;
        }
        if (a == 9 && b == 1)
        {
            cout << 9 << ' ' << 10 << endl;
            return 0;
        }
        if (a > b || b-a > 1)
        {
            cout << -1 << endl;
            return 0;
        }
        cout << a << '9' << ' ' << b << '0' << endl;
     
        return 0;
    }
    
  • 相关阅读:
    Python:解析PDF文本及表格——pdfminer、tabula、pdfplumber 的用法及对比
    2018数学建模国赛B题
    目标检测综述整理
    numpy实现两层layer
    应用安全
    应用安全
    应用安全
    应用安全
    应用安全
    应用安全
  • 原文地址:https://www.cnblogs.com/YDDDD/p/11772249.html
Copyright © 2011-2022 走看看