Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // AndeyLess
- //
- // Created by Kadir Kadyrov on 08.07.2020.
- // Copyright © 2020 Kadir Kadyrov. All rights reserved.
- //
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- #include <string>
- #define INF 1000000000
- #define MAXE 1000000
- #define MAXV 1000
- using namespace std;
- int ex23(int n) {
- int ans = 0;
- for(int i = 1; i <= n; i++) {
- if(n % i == 0) {
- ans++;
- }
- }
- return ans;
- }
- int ex23_1(int n) {
- int ans = 0;
- for (int i = 1; i <= sqrt(n); i++) { // div = 2 -> n/2
- if(n % i == 0) {
- ans += 2;
- }
- }
- if (sqrt(n) * sqrt(n) == n) { // when n = x * x -> ans - 1
- ans--;
- }
- return ans;
- }
- int sumOfDig1(int n) {
- int ans = 0;
- while(n > 0) { // 102 -> 10
- ans += n % 10;
- n /= 10;
- }
- return ans;
- }
- int sumOfDig2(int n) {
- string s = to_string(n);
- int ans = 0;
- for (int i = 0; i < s.size(); i++) {
- ans += (s[i] - '0'); // '0' - 42 '1' - 43, '0' - 42 - '0' = 0, '1' - '0' = 1
- }
- return ans;
- }
- int sumOfDig3(int n) {
- int ans = (n % 10) + ((n / 10) % 10) + (n / 100);
- return ans;
- }
- /// n%7 sum(n) %7
- void ex25() {
- for (int x = 100; x <= 999; x++) {
- if (x % 7 == 0 && sumOfDig1(x) % 7 == 0)
- cout << x << endl;
- }
- }
- int main() {
- ex25();
- //cout << ex23(10) << ' ' << ex23_1(10) << ' ' << ex23_1(25) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement