题解 | #[NOIP2015]金币#
[NOIP2015]金币
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int k =in.nextInt();//第几天 int sum=0;//金币数 int t = 1;//当前金币数第几天 int s = 1;//当前金币数 for(int i=1;i<=k;i++){ sum+=s; if(t==s){ t=1; s++; }else{ t++; } } System.out.print(sum); } }