96-n-1位数
内存限制:64MB
时间限制:3000ms
特判: No
通过数:30
提交数:47
难度:1
题目描述:
已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数。
输入描述:
第一行为M,表示测试数据组数。 接下来M行,每行包含一个测试数据。
输出描述:
输出M行,每行为对应行的n-1位数(忽略前缀0)。如果除了最高位外,其余位都为0,则输出0。
样例输入:
4 1023 5923 923 1000
样例输出:
23 923 23 0
C/C++ AC:
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <cmath> 6 #include <stack> 7 #include <set> 8 #include <map> 9 #include <queue> 10 #include <climits> 11 12 using namespace std; 13 int n, m; 14 15 int main() 16 { 17 cin >>n; 18 while (n --) 19 { 20 char str[10]; 21 cin >>str; 22 int str_leng = strlen(str); 23 int int_str = atoi(str); // 字符串 ---> 整数 24 int temp = ceil(pow(10, str_leng - 1)); // ceil 向上取整 25 cout <<int_str % temp <<endl; 26 } 27 }