Skip to content

Instantly share code, notes, and snippets.

@chomado
Created August 4, 2014 05:09
Show Gist options
  • Save chomado/c3d683b8fb1fc85676d9 to your computer and use it in GitHub Desktop.
Save chomado/c3d683b8fb1fc85676d9 to your computer and use it in GitHub Desktop.
#include <iostream>
const int first = 100000;
int round_up(int price) // 1000円未満を切り上げ
{
if (price%1000 == 0) {
return price;
}
int complement = 1000 - price%1000; // 補数
return (price + complement);
}
int get_dept(int n) // n週間後
{
int dept = first;
for (int i=0; i<n; i++) {
dept += dept * 0.05;
dept = round_up(dept);
}
return dept;
}
int main()
{
int n;
std::cin >> n;
std::cout << get_dept(n) << std::endl;
}
@chomado
Copy link
Author

chomado commented Aug 4, 2014

[Wandbox]三へ( へ՞ਊ ՞)へ ハッハッ http://melpon.org/wandbox/permlink/DyaNA0Plb6Fm9ARD
input: // 整数 n
5

output: // n 週間後の返済額 (利子5%/週、1000円未満切り上げ)
130000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment