31 lines
716 B
C++
31 lines
716 B
C++
|
#include<stdcpp.h>
|
||
|
using namespace std;
|
||
|
class Solution{
|
||
|
public:
|
||
|
int totalMoney(int n){
|
||
|
int monday = 0;
|
||
|
int rlt = 0;
|
||
|
for(int i = 1 ; i<=n ;i++){
|
||
|
if(i%7==1){
|
||
|
monday = monday + 1;
|
||
|
rlt += monday;
|
||
|
cout<<monday<<endl;
|
||
|
}else{
|
||
|
int amount = i%7;
|
||
|
if(!amount) amount = 7;
|
||
|
cout<< monday + amount - 1 <<endl;
|
||
|
rlt += monday + amount - 1 ;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
cout<<endl;
|
||
|
return rlt;
|
||
|
}
|
||
|
};
|
||
|
int main(){
|
||
|
int n;
|
||
|
Solution sol;
|
||
|
cout<<sol.totalMoney(4)<<endl;
|
||
|
cout<<sol.totalMoney(10)<<endl;
|
||
|
cout<<sol.totalMoney(20)<<endl;
|
||
|
}
|