//
// main.cpp
// ROW
//
// Created by Sebastian Mróz on 23/09/2015.
// Copyright (c) 2015 Sebastian Mróz. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
// insert code here...
unsigned long long a;
unsigned long long b;
unsigned long long k;
long long suma = 0 ;
int counter = 0 ;
long long int number_length;
string number;
cin >> k >> a >> b;
while( a%k != 0)
a++;
for( unsigned long long i = a; i <= b; i+=k ){
number = to_string(i);
number_length = number.length();
suma = 0;
for( int j = 0; j < number_length; j++){
long long int x = number[ number_length-j-1 ];
x-=48;
suma += (pow(10,j) - k*x)*x;
}
if( suma == 0 ){
counter++;
}
}
cout << counter << endl;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | // // main.cpp // ROW // // Created by Sebastian Mróz on 23/09/2015. // Copyright (c) 2015 Sebastian Mróz. All rights reserved. // #include <iostream> #include <cmath> #include <string> using namespace std; int main(int argc, const char * argv[]) { // insert code here... unsigned long long a; unsigned long long b; unsigned long long k; long long suma = 0 ; int counter = 0 ; long long int number_length; string number; cin >> k >> a >> b; while( a%k != 0) a++; for( unsigned long long i = a; i <= b; i+=k ){ number = to_string(i); number_length = number.length(); suma = 0; for( int j = 0; j < number_length; j++){ long long int x = number[ number_length-j-1 ]; x-=48; suma += (pow(10,j) - k*x)*x; } if( suma == 0 ){ counter++; } } cout << counter << endl; return 0; } |
English