Train(求從前開始數的第i個數是從n開始數的第幾個數)
阿新 • • 發佈:2018-12-03
問題 A: Train
時間限制: 1 Sec 記憶體限制: 128 MB
題目描述
There is an N-car train.
You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
Constraints
1≤N≤100
1≤i≤N
輸入
Input is given from Standard Input in the following format:
N i
輸出
Print the answer.
樣例輸入
複製樣例資料
4 2
樣例輸出
3
提示
The second car from the front of a 4-car train is the third car from the back.
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm> #include <map> #include <set> #include <vector> #include <string> #include <stack> #include <queue> typedef long long LL; using namespace std; int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); int n, i; scanf("%d %d", &n, &i); printf("%d\n", n - i + 1); return 0; } /**/