A1223 | [COCI-2011_2012-contest2]#1 FUNKCIJA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mirko has written the following function:
int fun() {
int ret = 0;
for (int a = X1; a <= Y1; ++a)
for (int b = X2; b <= Y2; ++b)
...
for (int <N-th> = XN; <N-th> <= YN; ++<N-th>)
ret = (ret + 1) % 1000000007;
return ret;
}
function fun: longint;
var ret: longint;
a, b, ... , y, z: longint;
begin ret := 0;
for a := X1 to Y1 do for b := X2 to Y2 do ...
for <N-th> := XN to YN do ret := (ret + 1) mod 1000000007;
fun := ret;
end;
<N-th> denotes the Nth lowercase letter of the English alphabet. Each Xi and Yi denotes either a positive integer less than or equal to 100 000 or a name of a variable that some outer loop iterates over.
For example, X3 can be either a, b, or an integer literal. At least one of Xi and Yi will be an integer literal (i.e. not a variable name) for every i.
Compute the return value of the function.
int fun() {
int ret = 0;
for (int a = X1; a <= Y1; ++a)
for (int b = X2; b <= Y2; ++b)
...
for (int <N-th> = XN; <N-th> <= YN; ++<N-th>)
ret = (ret + 1) % 1000000007;
return ret;
}
function fun: longint;
var ret: longint;
a, b, ... , y, z: longint;
begin ret := 0;
for a := X1 to Y1 do for b := X2 to Y2 do ...
for <N-th> := XN to YN do ret := (ret + 1) mod 1000000007;
fun := ret;
end;
<N-th> denotes the Nth lowercase letter of the English alphabet. Each Xi and Yi denotes either a positive integer less than or equal to 100 000 or a name of a variable that some outer loop iterates over.
For example, X3 can be either a, b, or an integer literal. At least one of Xi and Yi will be an integer literal (i.e. not a variable name) for every i.
Compute the return value of the function.
输入格式
The first line of input contains the positive integer N (1 ≤ N ≤ 26).
For the next N lines, the i th line contains Xi and Yi, separated with a space. If Xi and Yi are both integer literals, then Xi ≤ Yi.
For the next N lines, the i th line contains Xi and Yi, separated with a space. If Xi and Yi are both integer literals, then Xi ≤ Yi.
输出格式
The first and only line of output must contain the return value of the function.
输入输出样例
输入 #1
2 1 2 a 3
输出 #1
5
输入 #2
3 2 3 1 2 1 a
输出 #2
10
输入 #3
3 1 2 a 3 1 b
输出 #3
11
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted