public class Main{
public static long array[] = new long[61];
public static long num_of_ways(int n){
if(array[n] == 0) {
array[n] = num_of_ways(n-1) + num_of_ways(n-2) + num_of_ways(n-3);
return array[n];
}
else {
return array[n];
}
}
java.
util.
Scanner i
= new java.
util.
Scanner(System.
in); int n = i.nextInt();
array[0] = 1;
array[1] = 1;
array[2] = 2;
System.
out.
print(num_of_ways
(n
)); }
}
cHVibGljIGNsYXNzIE1haW57CglwdWJsaWMgc3RhdGljIGxvbmcgYXJyYXlbXSA9IG5ldyBsb25nWzYxXTsKCXB1YmxpYyBzdGF0aWMgbG9uZyBudW1fb2Zfd2F5cyhpbnQgbil7CgkJaWYoYXJyYXlbbl0gPT0gMCkgewoJCQlhcnJheVtuXSA9IG51bV9vZl93YXlzKG4tMSkgKyBudW1fb2Zfd2F5cyhuLTIpICsgbnVtX29mX3dheXMobi0zKTsKICAgICAgICAJcmV0dXJuIGFycmF5W25dOwogICAgCX0KCQllbHNlIHsKICAgICAgICAJcmV0dXJuIGFycmF5W25dOwogICAgCX0KCX0KCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbiAJewoJCWphdmEudXRpbC5TY2FubmVyIGkgPSBuZXcgamF2YS51dGlsLlNjYW5uZXIoU3lzdGVtLmluKTsKCQlpbnQgbiA9IGkubmV4dEludCgpOwoJCWFycmF5WzBdID0gMTsKICAgIAlhcnJheVsxXSA9IDE7CiAgICAJYXJyYXlbMl0gPSAyOwoJCVN5c3RlbS5vdXQucHJpbnQobnVtX29mX3dheXMobikpOwoJfQp9