Created
August 4, 2014 05:09
-
-
Save chomado/c3d683b8fb1fc85676d9 to your computer and use it in GitHub Desktop.
[C++] AOJ、闇金の借金問題。 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007&lang=jp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[Wandbox]三へ( へ՞ਊ ՞)へ ハッハッ http://melpon.org/wandbox/permlink/DyaNA0Plb6Fm9ARD
input: // 整数 n
5
output: // n 週間後の返済額 (利子5%/週、1000円未満切り上げ)
130000