You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
636 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
//倒推
/**
小学常用倒推法:
最后遇花喝一斗前0+1=1
最后遇店加一倍,则原有:1÷2=1/2
第二次遇花喝一斗原有1/2+1=3/2
第二次遇店加一倍则原有3/2÷2=3/4
第一次遇花喝一斗原有3/4+1=7/4
第一次遇店加一倍则原有7/4÷2=7/8
综合以上得7/8斗 。
*/
int main() {
double sum = 0;
for (int i = 0; i < 6; ++i) {
if (i % 2 == 0)
sum += 1;
else {
sum = sum / 2;
}
}
cout << sum << endl;
return 0;
}