ICPC Mansoura Training lvl0 Contest #2 — Newcomers'23

Revision en5, by nabil_salah, 2023-03-13 21:48:20

A. In Search of an Easy Problem

As the name suggest it is an easy problem all what is needed is to take a string s as input and print Mohamed Salah

#include<iostream>
using namespace std;
int main()
{
 string str;cin>>str;
 cout<<"Mohamed Salah";
}

F. N and T

In this problem we want to find a number that is divisible by t and has n digits. But we found a series of problems:

  1. n can be 100 -> there is no data type that handles such a big number (long long take up to pow(2,64))

  2. How can I easily get a number divisible by t

The answer is t itself and

what about multiplying the number by 10 until I get the desired length? why 10: multiplying by 10 will keep the divisibility state (2x10 is divisible by 2 and 2x10x10 is still divisible by 2....)

so the answer will be the t multiplied by 10 until I reach the desired length. -> problem 2 solved

multiplying by 10 means adding 0 to the end of the number (2x10 = 20, 330x10 = 3300)

so we can print the t followed by zeros -> problem 1 solved

but when I will print -1? the answer is if the number of digits in t is less than n as the smallest number is divisble by t is t itself

#include <iostream>
#include <vector>
using namespace std ;
int32_t main() {
    int n,t;cin>>n>>t;
    if(t == 10 && n== 1){
        cout<<"-1";
    }else{
        cout<<t;
        n--;
        if(t == 10)n--;
        for (int i = 0; i < n; ++i) {
            cout<<"0";
        }
    }
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en34 English nabil_salah 2023-03-16 01:02:16 0 (published)
en33 English Eman_Abdelhaleem 2023-03-15 01:59:14 35 Tiny change: ' $0$.\n\n</spoi' -> ' $0$.\n\n<B>Time Complexity :</B> $O(N)$\n\n</spoi'
en32 English Eman_Abdelhaleem 2023-03-15 01:57:35 10 Tiny change: 'follows)\nSurely, ' -> 'follows)\n\nSurely, '
en31 English Eman_Abdelhaleem 2023-03-15 01:48:08 1658
en30 English nabil_salah 2023-03-15 00:44:28 194 Tiny change: 'h"_** \n\n-_**Time Co' -> 'h"_** \n\n_**Time Co'
en29 English AyaHazem61 2023-03-15 00:11:54 6 Tiny change: ' elements in odd indices.\nthen we com' -> ' elements at odd indices.\nThen we com'
en28 English AyaHazem61 2023-03-15 00:10:38 851
en27 English AyaHazem61 2023-03-14 23:48:36 2 Tiny change: '">\n```C++#include <' -> '">\n```C++\n#include <'
en26 English AyaHazem61 2023-03-14 23:47:28 7
en25 English AyaHazem61 2023-03-14 23:46:10 16
en24 English AyaHazem61 2023-03-14 23:44:57 733
en23 English AbdelhakiemOsama 2023-03-14 23:43:28 60
en22 English AbdelhakiemOsama 2023-03-14 23:40:20 45
en21 English AbdelhakiemOsama 2023-03-14 23:35:43 805
en20 English AyaHazem61 2023-03-14 23:30:32 464
en19 English nabil_salah 2023-03-14 23:11:00 99
en18 English khaled-waleed 2023-03-14 23:05:17 206
en17 English khaled-waleed 2023-03-14 22:55:59 293
en16 English khaled-waleed 2023-03-14 22:08:10 2 Tiny change: ' follows\n1. Sort ' -> ' follows\n\n1. Sort '
en15 English khaled-waleed 2023-03-14 22:07:41 1806
en14 English khaled-waleed 2023-03-14 21:41:44 39
en13 English khaled-waleed 2023-03-14 21:40:34 14
en12 English khaled-waleed 2023-03-14 21:39:16 0 Tiny change: '-1, j-1)\n- bottom rig' -> '-1, j-1)\nbottom rig'
en11 English khaled-waleed 2023-03-14 21:37:28 2556
en10 English Eman_Abdelhaleem 2023-03-14 16:29:34 9
en9 English Eman_Abdelhaleem 2023-03-14 16:28:15 16 Tiny change: 'lution">\n\n</spoile' -> 'lution">\nNot finished yet\n</spoile'
en8 English Eman_Abdelhaleem 2023-03-14 16:24:26 181 Tiny change: 'on">\nIf $a%b=0$ ($a$ is ' -> 'on">\nIf $ a%b=0 $ ($a$ is '
en7 English Eman_Abdelhaleem 2023-03-14 15:59:30 1242
en6 English Eman_Abdelhaleem 2023-03-14 15:43:15 210
en5 English nabil_salah 2023-03-13 21:48:20 1398 Tiny change: ' **_t_**\nThe answ' -> ' **_t_**\n\nThe answ'
en4 English nabil_salah 2023-03-13 02:14:06 11
en3 English nabil_salah 2023-03-13 02:12:43 256 Making first prob editorial
en2 English nabil_salah 2023-03-13 02:04:19 2
en1 English nabil_salah 2023-03-13 01:58:29 171 Initial revision (saved to drafts)