355A - Vasya and Digital Root - CodeForces Solution


constructive algorithms implementation *1100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>

#define ll long long
#define AHMADZERIE ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ln "\n"
#define reb(i, a, b) for(int i=a;i<=b;i++)
#define sq(a) a*a
#define enter(a, n) for(int i=0;i<n;i++){cin>>a[i];}
#define out(a, n) for(int i=0;i<n;i++){cout<<a[i];}
#define pb(a) push_back(a);
#define enterv(v) for(int &x:v){cin >>x;}
#define all(v) v.begin(), v.end()
#define cont continue
#define br break
#define F first
#define S second
using namespace std;
const ll N = 20000000;
ll dp[N];

int myAtoi(string s) {
    long long val = 0;
    bool ok = 0;
    int i = 0, n = s.size();
    while (i < n && s[i] == ' ') { i++; }
    if (i == n) { return 0; }
    if (s[i] == '-') {
        ok = 1;
        i++;
    } else if (s[i] == '+') {
        ok = 0;
        i++;
    }
    while (i < n && isdigit(s[i])) {
        val = 10 * val + (s[i] - '0');
        i++;
        if (val > 1e10) { break; }
    }
    if (ok) { val = -val; }
    if (val >= INT_MAX) { val = INT_MAX; }
    if (val <= INT_MIN) { val = INT_MIN; }
    return (int) val;
}

int main() {
    AHMADZERIE
    /*ll n;
    cin >> n;
    map<int,bool>mp;
    int arr[n];
    int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0, cnt6 = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        mp[arr[i]]= false;
        if (arr[i] < 0) {
            cnt1++;
            cnt4 = cnt1;
        }
        else if (arr[i] > 0) {
            cnt2++;
            cnt5 = cnt2;
        }
        else {
            cnt3++;
            cnt6 = cnt3;
        }
    }
    int arr1[n];
    int arr2[n];
    int arr3[n];
    int c1=0,c2=0,c3=0;
    if(cnt2==0){
        for (int i = 0; i < n; ++i) {
            if(c2==2){br;}
            if(arr[i]<0){
                arr2[c2]=arr[i];
                c2++;
            }
        }
    }*/
    int n, k;
    cin >> n >> k;
    if (k == 0 && n != 1) {
        cout << "No solution" << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (k > 0) {
            cout << k;
            k = 0;
        } else cout << 0;
    }
}


Comments

Submit
0 Comments
More Questions

219A - k-String
952A - Quirky Quantifiers
451B - Sort the Array
1505H - L BREAK into program
171E - MYSTERIOUS LANGUAGE
630D - Hexagons
1690D - Black and White Stripe
1688D - The Enchanted Forest
1674C - Infinite Replacement
712A - Memory and Crow
1676C - Most Similar Words
1681A - Game with Cards
151C - Win or Freeze
1585A - Life of a Flower
1662A - Organizing SWERC
466C - Number of Ways
1146A - Love "A"
1618D - Array and Operations
1255A - Changing Volume
1710C - XOR Triangle
415C - Mashmokh and Numbers
8A - Train and Peter
591A - Wizards' Duel
1703G - Good Key Bad Key
1705A - Mark the Photographer
1707A - Doremy's IQ
1706B - Making Towers
1325B - CopyCopyCopyCopyCopy
1649C - Weird Sum
1324B - Yet Another Palindrome Problem