//Tomasz Czarkowski #include<iostream> using namespace std; int sumakwadr(int n){ int m=1; int n1=n; int c=0; while(n1){ m=n1-((n1/10)*10); c+=m*m; n1=n1/10; } return c; } main(){ long long n=0,k,a,b,d=0; cin>>k>>a>>b; n=a; while(n<=b){ if(k*sumakwadr(n)==n){ d++; } n++; } cout<<d; }
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 | //Tomasz Czarkowski #include<iostream> using namespace std; int sumakwadr(int n){ int m=1; int n1=n; int c=0; while(n1){ m=n1-((n1/10)*10); c+=m*m; n1=n1/10; } return c; } main(){ long long n=0,k,a,b,d=0; cin>>k>>a>>b; n=a; while(n<=b){ if(k*sumakwadr(n)==n){ d++; } n++; } cout<<d; } |