Title Description
For positive integer n,k, we define such a function F, which satisfies the following law
Now for N and k, your task is to calculate the value of f (n,k) .
Input
The first is an integer t, which indicates that there is a T group of data next to each group of data is N and K (1<=n,k<=108)
Output
Prints the value of f (n,k), one row for each output
Sample input3 1 1 2 1 3 1Sample output-1 1-2
Find the rules.
1#include <iostream>2#include <stdio.h>3 intMain ()4 {5 using namespacestd;6 Long Longc,i,j=1, m,n,t=0, rankl=0;7 intA;8scanf"%d",&a);9 while(SCANF ("%lld%lld", &m,&n)! =EOF) {Ten if(m==1&&n==1) {printf ("-1\n");} One Else{ Ac=m/(2*n); -rankl=n*c*N; - for(i=2*n*c+1; i<=m;i++) the { -t++; - if(t>N) - { +J + +; -t=1; + } A if((j+2)%2==0) at { -rankl=rankl+i; - } - Else - { -rankl=rankl-i; in } - } toprintf"%lld\n", RANKL); +t=0; rankl=0; j=1; - }} the return 0; * } $ /**************************************************************Panax Notoginseng problem:1206 - user:2014217052 the language:c++ + Result: Correct A time:614 Ms the memory:1504 KB + ****************************************************************/
2015 Anhui Province race B. Summation