mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-13 02:38:37 +08:00
init
This commit is contained in:
19
23/10/Q2652.h
Normal file
19
23/10/Q2652.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Created by 李洋 on 2023/10/17.
|
||||
//
|
||||
|
||||
#ifndef LEECODE_C_Q2652_H
|
||||
#define LEECODE_C_Q2652_H
|
||||
|
||||
class Q2652 {
|
||||
public:
|
||||
int f(int n, int m) {
|
||||
return (m + n / m * m) * (n / m) / 2;
|
||||
}
|
||||
|
||||
int sumOfMultiples(int n) {
|
||||
return f(n, 3) + f(n, 5) + f(n, 7) - f(n, 3 * 5) - f(n, 3 * 7) - f(n, 5 * 7) + f(n, 3 * 5 * 7);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //LEECODE_C_Q2652_H
|
||||
Reference in New Issue
Block a user