丢石子的c语言代码问题

img


怎么写代码啊

同学你好(^O^)
QWQ青稞学生偶遇
我也研究到这个题,但是没想明白这题例子中的输入三,输出四是咋整的

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n = 0;
    cin >> n;
    int ans = pow(2, n - 1);
    cout << ans % 998244353 << endl;
    return 0;
}

img

就是算这个

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
int n=0;
int s=0;
Scanner sc = new Scanner(System.in);
while(sc.hasNext()==true){
n=0;
s=0;
n= sc.nextInt();
s= (int) Math.pow(2,n-1);
s=s%998244353;
System.out.println(s);
}
}
}
我这么写哪里不对?求指点